Need Help with this code?
Need help with the following code to run (from the book) keeps failing when it hits objCommand.ExecuteNonQuery()?? New to programming..... Also is there anywhere that I can get some easy to follow code that writes to a data source, because I'm still a bit confused after reading chapter 16. I need more info on displaying reading and writing to a database. Thanks
Dim objConnection As SqlConnection = New SqlConnection _
("server=(local);database=pubs;integrated security=true")
Dim objCommand As SqlCommand = New SqlCommand
objCommand.Connection = objConnection
objCommand.CommandText = "INSERT INTO authors " & _
"(au_id, au_lname, au_fname, contract) " & _
"VALUES(@au_id,@au_lname,@au_fname,contract)"
objCommand.Parameters.Add("@au_id", TextBox1.Text)
objCommand.Parameters.Add("@au_lname", TextBox2.Text)
objCommand.Parameters.Add("@au_fname", TextBox3.Text)
objCommand.Parameters.Add("@contract", CheckBox1.Checked)
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()
|