% if (Request.Form() <> "") then if (Request.Form("txt-titulo") = "" or Request.Form("txt-data_encerramento") = "" or Request.Form("txt-data_inicio") = "") then form_msg("Todos os campos devem estar preenchidos") end if call db_open() if db_scalar("select id_cf_pesquisa from CF_pesquisa where titulo = '"&Request.Form("txt-titulo")&"' ") <> "" then form_msg("A pesquisa "&Request.Form("txt-titulo")&" já existe.") end if 'response.Write(str_sql) if ( msg = "" )then con.execute(str_sql) :msg = "": form_msg("Pesquisa gravada.") end if end if function str_sql sql = "insert into CF_PESQUISA (" for each item in request.Form() if ((left(item,3) = "txt") or (left(item,3) = "chk") or (left(item,3) = "rdo") or (left(item,3) = "cmb")) then sql_campos = sql_campos & right(item,len(item) - 4)& ", " sql_valores = sql_valores & "'" &request.form(item) & "', " end if next sql = sql & left(sql_campos,len(sql_campos) -2) & ") values ("&left(sql_valores,len(sql_valores) -2) & ")" str_sql = sql end function %>