By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,632 Members | 1,499 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,632 IT Pros & Developers. It's quick & easy.

writing data to the database vb .net 2005 2.0- Important!!!

P: 6
hello,

I am using the code below to add to the database but for some reason i get an error message "provider". i donot know what am doing wrong. It is a whole table although at the moment am trying out with one field. i dont know if i should still have an sqldatasource on my web page as i am inserting into the database and not reading from it. please advise.......

Dim conn As String = System.Configuration.ConfigurationManager.Connecti onStrings("ConnectionString7").ConnectionString
Dim myConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(conn)
Dim MySQL As String = "INSERT INTO researcher (R_Surname) VALUES ('" + (TextBox9.Text) + " ')"
Dim cmd As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(MySQL, myConnection)
cmd.CommandType = System.Data.CommandType.Text
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("R_Surname", TextBox9.Text))
myConnection.Open()
cmd.ExecuteNonQuery()
myConnection.Close()
Apr 2 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.