G
Guest
Hello All,
Iam trying to ADD NEW RECORDS to my address book. but iam with an error,
when i call the FILL method of the SqlDataAdaptor. Looking 4 assistance.
The code is as follows
TIA.
-------------------------------
Private Sub Btn_Add_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btn_Add.Click
With mDaAddresses
.InsertCommand = New SqlCommand
With .InsertCommand
.Connection = Cn
.CommandText = "Insert into
addresses(contact_id,contact_name,"
.CommandText += " address01, address02, email, group_id)
values(@cid,@cname,@add1,@add2,@email,@gid)"
With .Parameters
.Add("@cid", SqlDbType.VarChar, 10, "Contact_Id")
.Add("@cname", SqlDbType.VarChar, 40, "Contact_Name")
.Add("@add1", SqlDbType.VarChar, 20, "Address01")
.Add("@add1", SqlDbType.VarChar, 20, "Address02")
.Add("@email", SqlDbType.VarChar, 20, "email")
.Add("@gid", SqlDbType.VarChar, 10, "Group_Id")
End With
End With
.AcceptChangesDuringFill = True
.TableMappings.Add("Table", "Addressess")
.MissingSchemaAction = MissingSchemaAction.AddWithKey
End With
mDaAddresses.Fill(mDsInsert)
Dim mDataRow As DataRow
mDataRow = mDsInsert.Tables("Addresses").NewRow()
mDataRow("contact_id") = Trim(Lbl_Contact.Text)
mDataRow("contact_name") = Trim(UCase(Txt_CName.Text))
mDataRow("address01") = Trim(Txt_Add01.Text)
mDataRow("address02") = Trim(Txt_Add02.Text)
mDataRow("email") = Trim(Txt_Email.Text)
mDataRow("group_id") = Trim(Cmb_Grps.SelectedIndex)
mDsInsert.Tables("addresses").Rows.Add(mDataRow)
mDaAddresses.Update(mDsInsert)
Iam trying to ADD NEW RECORDS to my address book. but iam with an error,
when i call the FILL method of the SqlDataAdaptor. Looking 4 assistance.
The code is as follows
TIA.
-------------------------------
Private Sub Btn_Add_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btn_Add.Click
With mDaAddresses
.InsertCommand = New SqlCommand
With .InsertCommand
.Connection = Cn
.CommandText = "Insert into
addresses(contact_id,contact_name,"
.CommandText += " address01, address02, email, group_id)
values(@cid,@cname,@add1,@add2,@email,@gid)"
With .Parameters
.Add("@cid", SqlDbType.VarChar, 10, "Contact_Id")
.Add("@cname", SqlDbType.VarChar, 40, "Contact_Name")
.Add("@add1", SqlDbType.VarChar, 20, "Address01")
.Add("@add1", SqlDbType.VarChar, 20, "Address02")
.Add("@email", SqlDbType.VarChar, 20, "email")
.Add("@gid", SqlDbType.VarChar, 10, "Group_Id")
End With
End With
.AcceptChangesDuringFill = True
.TableMappings.Add("Table", "Addressess")
.MissingSchemaAction = MissingSchemaAction.AddWithKey
End With
mDaAddresses.Fill(mDsInsert)
Dim mDataRow As DataRow
mDataRow = mDsInsert.Tables("Addresses").NewRow()
mDataRow("contact_id") = Trim(Lbl_Contact.Text)
mDataRow("contact_name") = Trim(UCase(Txt_CName.Text))
mDataRow("address01") = Trim(Txt_Add01.Text)
mDataRow("address02") = Trim(Txt_Add02.Text)
mDataRow("email") = Trim(Txt_Email.Text)
mDataRow("group_id") = Trim(Cmb_Grps.SelectedIndex)
mDsInsert.Tables("addresses").Rows.Add(mDataRow)
mDaAddresses.Update(mDsInsert)