W
Winshent
I need help with this. v simple.. but ive read a few postings regarding
this subject, but mine still doesnt work..
my problem lies with the insert command.. here is the output
###################################################
INSERT INTO tblCustomer( CustomerID , FirstName , LastName , Email )
VALUES ( ? , ? , ? , ? )
###################################################
Do i have to manually create this command?
Hers is my code below.
Public Function AddCustomer( _
ByVal CustomerID As Int64, _
ByVal Firstname As String, _
ByVal LastName As String, _
ByVal Email As String) as string
Dim ds As DataSet
Dim myTable As DataTable
Dim myNewRow As DataRow
ds = GetData("SELECT * FROM tblCustomer", "Customers")
myTable = ds.Tables("Customers")
myNewRow = myTable.NewRow
myNewRow.BeginEdit()
myNewRow.Item("CustomerID") = CustomerID
myNewRow.Item("FirstName") = Firstname
myNewRow.Item("LastName") = LastName
myNewRow.Item("Email") = Email
myNewRow.EndEdit()
ds.Tables("Customers").Rows.Add(myNewRow)
Dim s As String
s = "SELECT CustomerID, Firstname, LastName, Email FROM tblCustomer"
Dim da As OleDbDataAdapter = GetDataAdapter(s)
Dim cb As OleDbCommandBuilder
cb = New OleDbCommandBuilder(da)
da.UpdateCommand = cb.GetUpdateCommand
da.InsertCommand = cb.GetInsertCommand
da.DeleteCommand = cb.GetDeleteCommand
Try
da.Update(ds, myTable.TableName)
ds.AcceptChanges()
Catch ex As Exception
Return (ex.ToString) & da.InsertCommand.CommandText()
Finally
ds.Dispose()
End Try
Thanks in advance
this subject, but mine still doesnt work..
my problem lies with the insert command.. here is the output
###################################################
INSERT INTO tblCustomer( CustomerID , FirstName , LastName , Email )
VALUES ( ? , ? , ? , ? )
###################################################
Do i have to manually create this command?
Hers is my code below.
Public Function AddCustomer( _
ByVal CustomerID As Int64, _
ByVal Firstname As String, _
ByVal LastName As String, _
ByVal Email As String) as string
Dim ds As DataSet
Dim myTable As DataTable
Dim myNewRow As DataRow
ds = GetData("SELECT * FROM tblCustomer", "Customers")
myTable = ds.Tables("Customers")
myNewRow = myTable.NewRow
myNewRow.BeginEdit()
myNewRow.Item("CustomerID") = CustomerID
myNewRow.Item("FirstName") = Firstname
myNewRow.Item("LastName") = LastName
myNewRow.Item("Email") = Email
myNewRow.EndEdit()
ds.Tables("Customers").Rows.Add(myNewRow)
Dim s As String
s = "SELECT CustomerID, Firstname, LastName, Email FROM tblCustomer"
Dim da As OleDbDataAdapter = GetDataAdapter(s)
Dim cb As OleDbCommandBuilder
cb = New OleDbCommandBuilder(da)
da.UpdateCommand = cb.GetUpdateCommand
da.InsertCommand = cb.GetInsertCommand
da.DeleteCommand = cb.GetDeleteCommand
Try
da.Update(ds, myTable.TableName)
ds.AcceptChanges()
Catch ex As Exception
Return (ex.ToString) & da.InsertCommand.CommandText()
Finally
ds.Dispose()
End Try
Thanks in advance