I am new to aspx and sql. I have written some code with vb.net 2005 (visual studio) to do some calculations and poplate some textboxes on my web form.
I dont understand how to pass those values to a paramerter then use that value to write to my sql database. I found this code but the VALUES(.....................) in the single quotes are placed in the database and not the values themselves. So I tried without quotes and got strange error sayng the the value was some kind of column header. PLEASE HELP.
I am a novice programmer so please dont use to much technical jargon...thanks! :)
Dim oDR As System.Data.SqlClient.SqlDataReader
Dim oCom As System.Data.SqlClient.SqlCommand
Dim oConn As System.Data.SqlClient.SqlConnection
Try
oConn = New System.Data.SqlClient.SqlConnection("server=xxxxx.com; initial catalog=db303095; uid=dbo303095; pwd=XXXXXXXX")
oConn.Open()
oCom = New System.Data.SqlClient.SqlCommand()
oCom.Connection = oConn
'oCom.CommandText = "WRITE * To Children"
Dim surnX As String = TextBox1.Text
Dim middleX As String = TextBox2.Text
Dim firstX As String = TextBox3.Text
Dim ofstX As String = TextBox4.Text
*** so how to i pass the about variables to the values below ***
'The first set are the column names. Confirmed 18/11/09.
oCom.CommandText = "INSERT INTO Children(First,Middle,Last,Ofsted) VALUES(@abc,'textbox1.text','textbox4.text','textbox2.text') "
oCom.ExecuteNonQuery()
Catch
Response.Write("Error:" & Err.Description)
Finally
oDR = Nothing
oCom = Nothing
oConn.Close()
oConn = Nothing
End Try