miranda
01-14-2003, 04:17 AM
I have an access database with a table(serials) with 3 fields
SerialNum, Model, SixDigits
I want to add a new record. here is the code I have
DsSerial1 is the name of the dataset
the three variables i have that hold the values to be passed are
Dim newSerialNum, model As String
Dim newSerial As Integer
Dim drNew As System.Data.DataRow
drNew = Me.DsSerial1.serials.NewRow
drNew.Item("SerialNum") = newSerialNumber
drNew.Item("Model") = model
drNew.Item("SixDigits") = newSerial
Me.DsSerial1.serials.Rows.Add(drNew)
Any ideas on why this doesnt work but if i use the following ado this works
Dim rsADO As New ADODB.Recordset()
Dim cnADO As ADODB.Connection
cnADO = create_connection()
cnADO.Open()
rsADO.ActiveConnection = cnADO
rsADO.Open("SELECT * FROM serials", cnADO, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
rsADO.AddNew()
rsADO.Fields("SerialNum").Value = newSerialNumber
rsADO.Fields("Model").Value = model
rsADO.Fields("SixDigits").Value = newSerial
rsADO.Update()
rsADO.Close()
cnADO.Close()
SerialNum, Model, SixDigits
I want to add a new record. here is the code I have
DsSerial1 is the name of the dataset
the three variables i have that hold the values to be passed are
Dim newSerialNum, model As String
Dim newSerial As Integer
Dim drNew As System.Data.DataRow
drNew = Me.DsSerial1.serials.NewRow
drNew.Item("SerialNum") = newSerialNumber
drNew.Item("Model") = model
drNew.Item("SixDigits") = newSerial
Me.DsSerial1.serials.Rows.Add(drNew)
Any ideas on why this doesnt work but if i use the following ado this works
Dim rsADO As New ADODB.Recordset()
Dim cnADO As ADODB.Connection
cnADO = create_connection()
cnADO.Open()
rsADO.ActiveConnection = cnADO
rsADO.Open("SELECT * FROM serials", cnADO, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
rsADO.AddNew()
rsADO.Fields("SerialNum").Value = newSerialNumber
rsADO.Fields("Model").Value = model
rsADO.Fields("SixDigits").Value = newSerial
rsADO.Update()
rsADO.Close()
cnADO.Close()