943,928 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 18050
  • VB.NET RSS
Sep 11th, 2005
0

Having problems with adding a row to a DataSet

Expand Post »
Hello,

I am having a problem with adding a row to my DataSet. I think I know what the problem is, but not how to correct it. I have several bound text boxes that fill from the DataSet. The first column is a numeric and the next several are text strings. When I try to add the new row it hangs at the first entry and gives me a wrong type error. I think the problem is that when it tries to update from the text box with new information, it is trying to enter Text into a Numeric field. My question is how do I convert the data to the proper type during the update? I am including part of the code here for claification. The database is a one table Access database. VID is the Primary Key in the table.

Code:

Private Sub btnAdd_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

Dim drNew As System.Data.DataRow

drNew = Me.DsHeartland1.Customer.NewRow
drNew.Item("VID") = ("New VID")
drNew.Item("Customer Name") = ("New Customer Name")
drNew.Item("Address") = ("New Address")
drNew.Item("City") = ("New City")
drNew.Item("State") = ("New State")
drNew.Item("Zip") = ("New Zip")
drNew.Item("Phone 1") = ("New Phone 1")
drNew.Item("Phone 2") = ("New Phone 2")
drNew.Item("Phone 3") = ("New Phone 3")
drNew.Item("Fax") = ("New Fax")
drNew.Item("Email") = "New Email"
Me.DsHeartland1.Customer.Rows.Add(drNew)


The debugger will stop and error at the line adding "VID" which is a numeric entry.

Any help will be greatly appreciated!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TennKV is offline Offline
2 posts
since Sep 2005
Sep 20th, 2005
0

Re: Having problems with adding a row to a DataSet

Try this,
Convert.ToInt32("" + VariableName + "")
Reputation Points: 11
Solved Threads: 6
Junior Poster
Letscode is offline Offline
175 posts
since Feb 2005
Sep 21st, 2005
0

Re: Having problems with adding a row to a DataSet

Thanks for the suggestion. When I tried it I received an error saying that VID was not defined. I tried it without the extra quotes and + and had an error saying "This code has called into another function. When that function is finished the next statement will be executed". I am using .Net 2002, don't know if that would make a difference or not. It seems like it should be so simple and I am sure it is, just can't see it yet!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TennKV is offline Offline
2 posts
since Sep 2005
Sep 22nd, 2005
0

Re: Having problems with adding a row to a DataSet

Hi,

This book " Data base programming using vb.net and sqlserver" will help you to develop the full application in .Net.

try this link:http://www.vkinfotek.com

regards
bhar
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Bharati Krishna is offline Offline
19 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Help Me "error in file request cancelled by user"
Next Thread in VB.NET Forum Timeline: Ref. 20 textboxes on a form numerically





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC