I am using following code to Add New Record in a Table (Temp in this case). I want to save new record with this method i.e., non-SQL. It is not commiting changes. The "Update" statement has errors.
'Initialize Data Adapter and Data Table Objects
TempDA.Fill(TempDS, "Temp")
TempDT = TempDS.Tables("Temp") 'Temp is the name of table
'Store to Temporary Table
'Start Connection
If Cn.State = ConnectionState.Closed Then
Call StartConnection()
End If
TempNewRow = TempDT.NewRow()
TempNewRow("Pno") = NewPNo
TempNewRow("PLName") = tab1_namepl
'Add the new row
TempDT.Rows.Add(TempNewRow)
'Commit Changes
TempDS.AcceptChanges()
dsChanges = TempDS.GetChanges
TempDA.Update(dsChanges, "Temp")
'Increment Permit Number
NewPNo = NewPNo + 1
Cn.Close()
If TempDS.HasChanges(DataRowState.Added) Then
MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly, "Success")
End If
Please also let me know which method for "Saving" record is fast (non-SQL).
'Initialize Data Adapter and Data Table Objects
TempDA.Fill(TempDS, "Temp")
TempDT = TempDS.Tables("Temp") 'Temp is the name of table
'Store to Temporary Table
'Start Connection
If Cn.State = ConnectionState.Closed Then
Call StartConnection()
End If
TempNewRow = TempDT.NewRow()
TempNewRow("Pno") = NewPNo
TempNewRow("PLName") = tab1_namepl
'Add the new row
TempDT.Rows.Add(TempNewRow)
'Commit Changes
TempDS.AcceptChanges()
dsChanges = TempDS.GetChanges
TempDA.Update(dsChanges, "Temp")
'Increment Permit Number
NewPNo = NewPNo + 1
Cn.Close()
If TempDS.HasChanges(DataRowState.Added) Then
MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly, "Success")
End If
Please also let me know which method for "Saving" record is fast (non-SQL).