Error adding rows to tables

G

Guest

running vb.net 2003 & SQL 2005

I have the following function that is meant to add a row to a table... but
i keep getting an error and i dont understand why. Ive spent a couple of
days on this now, has anybody any suggestions ?

Error :-
'row' argument cannot be null.
Parameter name: row

Code :-

Private Manager As CurrencyManager
Public sLicence As String
Private Orig_Accounts As New DataSet
Private NewRow As DataRow
Private NewRecordFlag As Boolean = False



Private Function ValidateChanges()
Manager.EndCurrentEdit()
If NewRecordFlag Then
Try
' THIS IS WHERE THE ERROR OCCOURS
Orig_Accounts.Tables("TBL_OrigAccounts").Rows.Add(NewRow)
Catch DBError As Exception
Console.WriteLine(DBError.Message)
Exit function
End Try
SetNewData()
NewRow = Orig_Accounts.Tables("TBL_OrigAccounts").NewRow
BindControls()
End If
If Orig_Accounts.HasChanges(DataRowState.Modified) Then
If MsgBox("Update changes to Licence " & sLicence & " ?",
MsgBoxStyle.OKCancel, "Profile Update") = MsgBoxResult.OK Then
Try
SQL_COMMANDBUILDER.DataAdapter = SQL_DATAADAPTER
SQL_COMMANDBUILDER.GetUpdateCommand()
SQL_DATAADAPTER.Update(Orig_Accounts, "TBL_OrigAccounts")
Orig_Accounts.AcceptChanges()
Catch ex As Exception
' Tempory
MsgBox(ex.Message)
End Try
End If
Else
If Orig_Accounts.HasChanges(DataRowState.Added) Then
SQL_COMMANDBUILDER.DataAdapter = SQL_DATAADAPTER
SQL_COMMANDBUILDER.GetUpdateCommand()
SQL_DATAADAPTER.Update(Orig_Accounts, "TBL_OrigAccounts")
Orig_Accounts.AcceptChanges()
End If
End If
NewRecordFlag = False
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top