| | |
Having problems with adding a row to a DataSet
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2005
Posts: 2
Reputation:
Solved Threads: 0
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!
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!
•
•
Join Date: Sep 2005
Posts: 2
Reputation:
Solved Threads: 0
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!
•
•
Join Date: Aug 2004
Posts: 19
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- Trouble adding new row to DataTable (C#) (C#)
- FlexGrid issue and error "Invalid Row value".... (Visual Basic 4 / 5 / 6)
- My Hard Drive is having some SERIOUS problems (Troubleshooting Dead Machines)
- how to adding data in dataset (ASP.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Help Me "error in file request cancelled by user"
- Next Thread: Ref. 20 textboxes on a form numerically
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic eclipse editvb.net employees excel exists forms function html images isnumericfuntioncall lib listview map mobile module msaccess mssqlbackend mysql net number open page pan pdf picturebox picturebox2 port print printing printpreview problem record regex reuse right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure structures temp textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vb2008 vba vbnet vista visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winsock wpf wrapingcode xml





