Command Parameters

P

Paul

Can someone tell me why the following code does not work ?

It does not crash or cause errors and it creates a new row in the table
"tblusers" but the fields are NULL.

Sub doInsert()
'Create Insert string
Dim MySQL As String = "Insert into tblusers (USERTEXT) values (@Pnotes)"
'Set up connection to mysql database
Dim myConn As OdbcConnection = New
OdbcConnection("driver={MySql};uid=root;pwd=;server=127.0.0.1;database=dbnrg
plc;OPTION=17923")
Dim Cmd As New OdbcCommand(MySQL, myConn)
Cmd.Parameters.Add(New OdbcParameter("@Pnotes", Me.txtNotes.Text))
myConn.Open()
Cmd.ExecuteNonQuery()
myConn.Close()
End Sub

Thanks in Advance
 
S

S. Justin Gengo

Paul,

Run the debugger and see if the text box actually has a value in it.

My guess is that your code is clearing the text box on post back.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top