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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Putting data in a database VB2005

Status
Not open for further replies.

vonehle

Programmer
May 16, 2006
35
US
I think somebody responded to this thread in the VB.NET forum, but the thread was deleted before I could read it.

Anyway...

I have a webform that contains a shopping cart. A datagrid is created on the fly as the user selects items. Once the user clicks a "complete" button, the items they selected should be dumped into a Access database.

I've had projects that pulled data into a table from a database, but never just added to a database when nothing existed initially. I'm clueless on how to do this.
 
you need to use an insert command.

look at this


Just my opinion...I would consider using sql server for this type of project. you can run SP's and keep your insert's etc. on the server and execute the sp's from your form. I don't use access but I think 2003 lets you run SP's. I would look into that as well.
 
That definitely got me on the right track. I have one minor problem. Some of the info I want to dump into the DB comes directly from datarows in the datatable. I can't seem to come up with the right way to extract that data. For instance, the following isn't working...

Code:
Dim cmd As New OleDbCommand("INSERT INTO tblOrders (Cost)VALUES('" & objDR("Cost") & "')", New OleDbConnection(strConn))

 
Couldn't you open a DataAdapter and then use the CommandBuilder to Update() the table with all the values in the GridView? You would need to make sure the InsertCommand is formatted correctly and such but I think that would (may) be a clean and efficient way to do something from the grid like you are

____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top