G
Guest
Hello
I want to push the data in my datatable into my database. How must i do this? I have been told to create a insert query. I have done this and have a select statement below it to retrieve the Identity value
What i want to ask is how i add my insertCommand to the dataadapter
I keep getting a error when i click my 'Submit' button..
Update requires a valid InsertCommand when passed DataRow collection with new rows
Im Sure my coding is wrong cos i was trying to play around to see if i could fluke it
This is my coding..
Private Sub btnConfirmBooking_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirmBooking.Clic
Dim cmdInsRenter As New SqlCommand("InsRenterAndSelIdentity", cn
cmdInsRenter.CommandType = CommandType.StoredProcedur
'declare the parameter
cmdInsRenter.Parameters.Add("@Lname", SqlDbType.Char, 50
cmdInsRenter.Parameters.Add("@Fname", SqlDbType.Char, 50
cmdInsRenter.Parameters.Add("@Addr", SqlDbType.Char, 300
cmdInsRenter.Parameters.Add("@RenterPostcode", SqlDbType.Char, 50
cmdInsRenter.Parameters.Add("@RenterPhoneNo", SqlDbType.Char, 25
'now set the value
cmdInsRenter.Parameters("@Lname").Value = txtLname.Tex
cmdInsRenter.Parameters("@Fname").Value = txtFname.Tex
cmdInsRenter.Parameters("@Addr").Value = txtAddr.Tex
cmdInsRenter.Parameters("@RenterPostcode").Value = txtRenterPcode.Tex
cmdInsRenter.Parameters("@RenterPhoneNo").Value = txtRenterPhoneNo.Tex
Tr
cn.Open(
daRenter.Update(Mydataset.Tables("MyDataTable")
cmdInsRenter.ExecuteNonQuery(
Catch x As Exceptio
MsgBox(x.Message
Finall
cn.Close(
End Tr
End Su
plz can someone help to modify my coding
Thank u in advance
I want to push the data in my datatable into my database. How must i do this? I have been told to create a insert query. I have done this and have a select statement below it to retrieve the Identity value
What i want to ask is how i add my insertCommand to the dataadapter
I keep getting a error when i click my 'Submit' button..
Update requires a valid InsertCommand when passed DataRow collection with new rows
Im Sure my coding is wrong cos i was trying to play around to see if i could fluke it
This is my coding..
Private Sub btnConfirmBooking_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirmBooking.Clic
Dim cmdInsRenter As New SqlCommand("InsRenterAndSelIdentity", cn
cmdInsRenter.CommandType = CommandType.StoredProcedur
'declare the parameter
cmdInsRenter.Parameters.Add("@Lname", SqlDbType.Char, 50
cmdInsRenter.Parameters.Add("@Fname", SqlDbType.Char, 50
cmdInsRenter.Parameters.Add("@Addr", SqlDbType.Char, 300
cmdInsRenter.Parameters.Add("@RenterPostcode", SqlDbType.Char, 50
cmdInsRenter.Parameters.Add("@RenterPhoneNo", SqlDbType.Char, 25
'now set the value
cmdInsRenter.Parameters("@Lname").Value = txtLname.Tex
cmdInsRenter.Parameters("@Fname").Value = txtFname.Tex
cmdInsRenter.Parameters("@Addr").Value = txtAddr.Tex
cmdInsRenter.Parameters("@RenterPostcode").Value = txtRenterPcode.Tex
cmdInsRenter.Parameters("@RenterPhoneNo").Value = txtRenterPhoneNo.Tex
Tr
cn.Open(
daRenter.Update(Mydataset.Tables("MyDataTable")
cmdInsRenter.ExecuteNonQuery(
Catch x As Exceptio
MsgBox(x.Message
Finall
cn.Close(
End Tr
End Su
plz can someone help to modify my coding
Thank u in advance