Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datatable info

Status
Not open for further replies.

ck1999

Technical User
Dec 2, 2004
784
0
0
US
I am updating a program I wrote in VB5 to VB2008 express. I am trying to determine if when I update a dataset or a datatable do I have to write a update query or can I somehow link the textboxes/checkboxes/comboboxes to the fields in the table similarly to what was done in vb5. I have update already 1 database front end, but this database table only had about 30 fields. The other program is going to have I think over 100. The one with 30 fields seems to take about 2 - 3 seconds to update over the intranet and I am looking for a faster way. Also, wanted to avoid all the typing setting the textboxes value and then writing the query if there is a faster more efficient way.

Thanks is advance for your help.

Chris
 
Here's a quick rundown on how you can do this:

1) On the right of the Visual Studio IDE, at the bottom of Soultion Explorer pane, there is a tab named "Data Sources". Select that tab.

2) In Data Sources, right-click and select "Add New Data Source", then follow the Data Source Configuration wizard.

3) Once the data source is set up, expand it and select the table you want. When you select the table in the list, you should see a drop down arrow appear at the right of the table's name. Select the drop down and then select "Details" in the drop down list.

4) After selecting Details, left-click the table and drag it to a form. After this finishes, you should see controls for all the table's fields, and at the bottom of the Form pane, you should see a <table_name>DataSet, <table_name>BindingSource, <table_name>TableAdapter, <table_name>TableAdapterManager, and <table_name>BindingNavigator. At the top of the form, you should see navigation controls, as well as controls to add, delete and save.


Of course it can get a bit more involved, but this should get you started.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks for the reply. I will give it a try. However, it will be next week. I will post back with more questions I am sure.

Chris
 
I have it where it display all the information. I have not changed or modified anything (code or design layout) but get this error when modify a field and try to save

"Update requires a valid updatecommand when passed datarow collection with modified rows"


Code:
   Private Sub TblMSDSBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblMSDSBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.TblMSDSBindingSource.EndEdit()
  ERRORS HERE -->        Me.TableAdapterManager.UpdateAll(Me.Wizdata2014DataSet)
 
The Table Adapter needs 4 command objects to fully function: SelectCommand, InsertCommand, UpdateCommand and DeleteCommand. The SelectCommand is created automatically when you generate the TableAdapter with the Data Source Configuration wizard. You have to set up the InsertCommand, UpdateCommand and DeleteCommand.

Check out this link and see if it helps:
I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
I went to the updatecommand. Added new.

command text

UPDATE tblMSDS
SET MasterMSDSID =, MSDSNo =, ProductNumber =, ProductName =

Commandtype: text



Now I am getting "sytax error in update statement"

the error code line is
Me.TableAdapterManager.UpdateAll(Me.Wizdata2014DataSet)



This is a single table and not a joined table. There is a primary Key "MasterMSDSID"

The table has about 100 fields. Do I have to change the update command to point to each individual text box.

Thanks for the help.

Chris
 
Did you try having the TableAdapter automatically generate the commands?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Yes but it did not generate anything.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top