First go to following link
Secure connection and easy transaction handling in .Net
to understand the logic for the connection
and to get the idea of what objDB means.
Just create a objDB class from the above link provided and use the following code
to insert a record in the table named dog.
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSingle.Click
Dim str As String
Dim objDB As clsObjDB
Try
objDB = New clsObjDB
str = "insert into Dog (DogName,Active)values('Lika',1) "
objDB.ExecuteQuery(str)
objDB = Nothing
messagebox.Show("Successfully Inserted Single row in dog!!" & vbCrLf)
Catch ex As Exception
Messagebox.show(ex.ToString())
objDB = Nothing
End Try
End Sub
In the above function I have just created a new instance of clsObjDB andpassed the sql query in the ExecuteQuery function and that's it, it does the rest of the work.
No comments:
Post a Comment