i wanted to add data from a single form in vb to two tables in access but an error appears saying that the field customer_ID down to Contact_Number doesnt belong to the table record, though it really doesnt belong to that table.. but i already indicated the table for the customer_ID down to Contact_Number, which is Customer, in my sql statement...
pleeaase help!!! i cant seem to fix it... T-T..
Public Class Refill
Dim connect As New OleDb.OleDbConnection
Dim sql As String
Dim ds As New DataSet
Dim adapter As New OleDb.OleDbDataAdapter
Private Sub Savebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Savebtn.Click
Dim cb As New OleDb.OleDbCommandBuilder(adapter)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("record").NewRow()
dsNewRow.Item("Tank_Number") = TankNumber.Text
dsNewRow.Item("Price") = Price.Text
dsNewRow.Item("Customer_ID") = CustID.Text
dsNewRow.Item("Customer_Address") = Address.Text
dsNewRow.Item("First_name") = FirstName.Text
dsNewRow.Item("Last_Name") = LastName.Text
dsNewRow.Item("Contact_Number") = ContactNmbr.Text
ds.Tables("record").Rows.Add(dsNewRow)
adapter.Update(ds, "record")
MsgBox("New Record added to the Database")
End Sub
Private Sub Refill_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
connect.ConnectionString = "PROVIDER = Microsoft.jet.OLEDB.4.0;Data Source = d:\Gas Petronas.mdb"
connect.Open()
sql = "SELECT * FROM Product, Customer"
adapter = New OleDb.OleDbDataAdapter(sql, connect)
adapter.Fill(ds, "record")
connect.Close()
End Sub
End Class
This post has been edited by czach: 03 October 2009 - 01:29 AM

New Topic/Question
Reply




MultiQuote




|