Trouble in updating data

I'm new here.. i had trouble in declaring the InitializeCommand() for my program .... can anyone help me with the coding i did here? i modified from the tutorial in this web but it doesnt work and i dont know what to do now.. me...

Private Sub InitializeCommands()

' Preparing Insert SQL Command
** dataAdapter.InsertCommand = conn.CreateCommand()
dataAdapter.InsertCommand.CommandText = _
"INSERT INTO Student_Detail " + _
"(Student_Name, Gender, D_O_B, Place_Of_Birth, Birth_Swear_Certificate, Race, Religion, Address, Changes_Of_Address) " + _
"VALUES(@Student_Name, @Gender, @D_O_B, @Place_Of_Birth, @Birth_Swear_Certificate, @Race, @Religion, @Address, @Changes_Of_Address)"
AddParams(dataAdapter.InsertCommand, "Student_Name", "Gender", "Place_Of_Birth", "Birth_Swear_Certificate", "Race", "Religion", "Address", "Changes_Of_Address")
' Preparing Update SQL Command
dataAdapter.UpdateCommand = conn.CreateCommand()
dataAdapter.UpdateCommand.CommandText = _
"UPDATE Student_Detail SET " + _
"Gender = @Gender, D_O_B = @D_O_B, Place_Of_Birth = @Place_Of_Birth, Birth_Swear_Certificate = @Birth_Swear_Certificate," + _
" Race = @Race, Religion = @Religion, Address = @Address, Changes_Of_Address = @Changes_Of_Address" + _
"WHERE Student_Name = @Student_name"
AddParams(dataAdapter.UpdateCommand, "Student_Name", "Gender", "Place_Of_Birth", "Birth_Swear_Certificate", "Race", "Religion", "Address", "Changes_Of_Address")
' Preparing Delete SQL Command
dataAdapter.DeleteCommand = conn.CreateCommand()
dataAdapter.DeleteCommand.CommandText = "DELETE FROM Student_Detail WHERE Student_Name = @Student_Name"
AddParams(dataAdapter.DeleteCommand, "Student_Name")
End Sub

Private Sub AddParams(ByVal cmd As OleDbCommand, ByVal ParamArray cols() As String)
' Adding Hectice parameters in SQL Commands
Dim col As String
For Each col In cols
cmd.Parameters.Add("@" + col, SqlDbType.Char, 0, col)
End Sub

the trouble comes at the ** place.. why does that happens????
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!