Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Arrasted

usar umvariavel no INsert

Recommended Posts

o codigo da ag que pega os valores no db a partir de um list/menu

<select name="genero" class="form"><option>Escolha...</option><!--#include file="Con1.asp"--><%Set rs = Conn.Execute("SELECT id, genero FROM generos ORDER BY genero ASC")While Not rs.EOF Response.Write "<option value='"& rs("id") &"'>"& rs("genero") &"</option>"rs.MoveNextWendrs.CloseSet rs = Nothing%></select>

ainda nessa pag tenho

 

textfield nome = titulo

textarea nome = followup

textarea nome = tecnicos

------------------------------------------------------------

na pg de Inserção eu resgato tos os valores, normal:

minha pergunta crucial, pois nao manjo muito de ASP;... yem como selecionar a tabela em que irei inserir os dados usando uma variavel? tipo no INsert INTO ???

 

genero = Request.Form("genero")

titulo = Request.Form("titulo")

followup = Request.Form("followup")

tecnicos = Request.Form("tecnicos")

 

Set Conn = Server.CreateObject("ADODB.CONNECTION")Conn.Open "Driver={SQL Server};Server=local;Database=global;Uid=xlabs;Pwd=XXXXXXX;" theSQL = "INSERT INTO Acao (titulo, followup, tecnicos) values ('"theSQL = theSQL & titulotheSQL = theSQL & "', '"theSQL = theSQL & followuptheSQL = theSQL & "', '"theSQL = theSQL & tecnicostheSQL = theSQL & "')"Conn.Execute(theSQL)Conn.CloseSet Conn = Nothing

Compartilhar este post


Link para o post
Compartilhar em outros sites

se entendi você quer passar atraves do formulario o nome da tabela onde vai ser inserido os dados certo???

 

então pensando que você vai ter um campo ai no seu formulario chamado TABLE onde você vai passar o nome.. é so usar assim:

 

tabela_nome = Request.Form("table")

 

Set Conn = Server.CreateObject("ADODB.CONNECTION")Conn.Open "Driver={SQL Server};Server=local;Database=global;Uid=xlabs;Pwd=XXXXXXX;"theSQL = "INSERT INTO "& tabela_nome &" (titulo, followup, tecnicos) values ('"theSQL = theSQL & titulotheSQL = theSQL & "', '"theSQL = theSQL & followuptheSQL = theSQL & "', '"theSQL = theSQL & tecnicostheSQL = theSQL & "')"Conn.Execute(theSQL)Conn.CloseSet Conn = Nothing

Compartilhar este post


Link para o post
Compartilhar em outros sites

é isso mesmo que voce tá fazendo...está dando erro???o form está enviando como POST???

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.