473,797 Members | 3,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error adding rows to tables

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.EndCurr entEdit()
If NewRecordFlag Then
Try
' THIS IS WHERE THE ERROR OCCOURS
Orig_Accounts.T ables("TBL_Orig Accounts").Rows .Add(NewRow)
Catch DBError As Exception
Console.WriteLi ne(DBError.Mess age)
Exit function
End Try
SetNewData()
NewRow = Orig_Accounts.T ables("TBL_Orig Accounts").NewR ow
BindControls()
End If
If Orig_Accounts.H asChanges(DataR owState.Modifie d) Then
If MsgBox("Update changes to Licence " & sLicence & " ?",
MsgBoxStyle.OKC ancel, "Profile Update") = MsgBoxResult.OK Then
Try
SQL_COMMANDBUIL DER.DataAdapter = SQL_DATAADAPTER
SQL_COMMANDBUIL DER.GetUpdateCo mmand()
SQL_DATAADAPTER .Update(Orig_Ac counts, "TBL_OrigAccoun ts")
Orig_Accounts.A cceptChanges()
Catch ex As Exception
' Tempory
MsgBox(ex.Messa ge)
End Try
End If
Else
If Orig_Accounts.H asChanges(DataR owState.Added) Then
SQL_COMMANDBUIL DER.DataAdapter = SQL_DATAADAPTER
SQL_COMMANDBUIL DER.GetUpdateCo mmand()
SQL_DATAADAPTER .Update(Orig_Ac counts, "TBL_OrigAccoun ts")
Orig_Accounts.A cceptChanges()
End If
End If
NewRecordFlag = False
End Function

Aug 1 '06 #1
1 2681
You need to do this before the Rows.Add line:

NewRow = New DataRow

=============== =============== ========
David McCarter
www.vsdntips.com
VSDN Tips & Tricks .NET Coding Standards available at:
www.cafepress.com/vsdntips.20412485
"Peter Newman" wrote:
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.EndCurr entEdit()
If NewRecordFlag Then
Try
' THIS IS WHERE THE ERROR OCCOURS
Orig_Accounts.T ables("TBL_Orig Accounts").Rows .Add(NewRow)
Catch DBError As Exception
Console.WriteLi ne(DBError.Mess age)
Exit function
End Try
SetNewData()
NewRow = Orig_Accounts.T ables("TBL_Orig Accounts").NewR ow
BindControls()
End If
If Orig_Accounts.H asChanges(DataR owState.Modifie d) Then
If MsgBox("Update changes to Licence " & sLicence & " ?",
MsgBoxStyle.OKC ancel, "Profile Update") = MsgBoxResult.OK Then
Try
SQL_COMMANDBUIL DER.DataAdapter = SQL_DATAADAPTER
SQL_COMMANDBUIL DER.GetUpdateCo mmand()
SQL_DATAADAPTER .Update(Orig_Ac counts, "TBL_OrigAccoun ts")
Orig_Accounts.A cceptChanges()
Catch ex As Exception
' Tempory
MsgBox(ex.Messa ge)
End Try
End If
Else
If Orig_Accounts.H asChanges(DataR owState.Added) Then
SQL_COMMANDBUIL DER.DataAdapter = SQL_DATAADAPTER
SQL_COMMANDBUIL DER.GetUpdateCo mmand()
SQL_DATAADAPTER .Update(Orig_Ac counts, "TBL_OrigAccoun ts")
Orig_Accounts.A cceptChanges()
End If
End If
NewRecordFlag = False
End Function
Aug 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9028
by: Kragen Sitaker | last post by:
ERROR: Cannot insert a duplicate key into unique index pg_class_relname_nsp_index We've been getting this error in our application every once in a while --- typically once an hour to once a day, although it varies over time. The daemon that gets the error exits and restarts a few seconds later. Usually it's fine then, but sometimes the error happens three or more times in a row. Occasionally, instead, we get "ERROR: Cannot insert a...
4
34584
by: Saso Zagoranski | last post by:
Hi! I have a little search textbox, which goes through a dataset as the user types in the textbox... If the user types "1", then all the fields beginning with a 1 get shown in the datagrid... here's the problem... I load the dataSet with all possible entries at Form_Load event... but during the search I don't want to change the initial dataSet, so I have
4
5483
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
2
5511
by: a | last post by:
I get the error that "Argument"1": cannot convert from 'string' to 'System.Data.DataRow' at the foreach loop to add rows to the DataTable...any ideas how to fix this? Paul ================================================== private void button1_Click(object sender, System.EventArgs e) {
0
950
by: Brent Starkes | last post by:
ok.... this is a strange error and it only happens in 2 instances 1) it happens when the program is first compiled. a restart of the program solves the problem 2) and when its out of order .... eg ( 12 Mad dog, 34 may and bbb) where bbb is displayed twice. this bbb is displayed twice in both instances. here is the code:
11
2703
by: Steve Hoyer | last post by:
I am trying to deploy my first asp.net app to our webserver (2K server, IIS 5) My start page comes up and you can get to the subsequent pages that are tied into our sql server (2K). Each page has a datagrid that loads up just fine, but when I click on any link that updates the page, i.e. a column header to sort the database, it returns a 404 error. Any ideas why it works the for the inital load and not on a postback?
2
1614
by: James Wallace | last post by:
I hope that someone can help me out there with this problem. I get an itermittant problem with our web page that occurs about once every 10 to 15 days where the only way to fix the problem is to bounce the web server. The error can be seen below. I have looked at the stack trace and determined where the error is occuring but when I look at my code, where it says that I have an unhandled exception, I have error handling to handle it. ...
6
4434
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire row doesn't get filled. I have a connection and all that stuff. Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaceBet.Click ' Dim Myds As Footbet.DStable '...
0
4808
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having manually inserted a row in the table bound to the Combo box. The InsertAt Method of adding a row just does not work. Hope this helps anyone with this problem. john
4
2877
by: Steve | last post by:
hi all, i'm using DHTML to generate a dynamic table with adding removing and sorting rows the thing is after a row has been added at a position that i specify, if i try to delete it i get this error ! here's a chunk of code <script language='javascript' type='text/css' > function removeElement(divNum,arrayCode,elementId) {
0
9536
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10245
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.