No...i have "SELECT". I am following an example on a book from Microsoft and the example shows "select". I tried update and I get "error near *" error message.
Main Topics
Browse All TopicsI am trying to save a newly inserted row in the dataset and commit the changes back to the database in a vb.net windows project. I am creating the dataset when the form loads and then adding a row to that dataset when i execute the save code i created. Below is how i am creating the dataset:
Public Class frmMainForm
Dim BOL_DS As New DataSet <-----declaring the dataset
Private Sub frmMainForm_Load..........
Dim sSQL As String = "SELECT * FROM tblInfo"
Dim cn As New SqlConnection(My.Settings.
Dim da As New SqlDataAdapter(cn.CreateCo
If cn.State = ConnectionState.Closed Then
cn.Open()
End If
da.SelectCommand.CommandTe
da.Fill(BOL_DS)
End Sub
Then when i want to save the data to the dataset i am doing the following:
Dim dr As DataRow
dr = BOL_DS.Tables(0).NewRow
dr("Rec_ID") = Me.Rec_ID.Text
dr("Date") = Me.Todays_Date.Text
BOL_DS.Tables(0).Rows.Add(
I then commit the changes to the database as follows:
Dim sSQL As String = "SELECT * FROM tblInfo"
Dim cn As New SqlConnection(My.Settings.
Dim da As New SqlDataAdapter(sSQL, cn)
Dim cb As New SqlCommandBuilder(da)
'update dataset
da.Update(BOL_DS)
When I execute all of this code it all seems to work (no errors are thrown) but nothing gets saved back to the database. I am hoping somebody can shed some light on what is happening and what i am doing wrong. I am using vb.net & SQL server 2005.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: soteaPosted on 2007-06-27 at 07:18:47ID: 19372451
I then commit the changes to the database as follows:
Dim sSQL As String = "SELECT * FROM tblInfo"
is that a copy/paste error, or do you have a SELECT sSQL, instead of an UPDATE?