473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Updating Access database from dataset with visual basic (2005)

Hi,
I am new to this forum and have been troubled by this problem for the past few days. I would appreciate if someone would take a look and help me out.

I am using vb express 2005 edition... I have problem when updating MS Access database from dataset using vb(2005)
Expand|Select|Wrap|Line Numbers
  1. Dim sql As String = "SELECT * FROM SB_ADWarning"
  2. Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\SB_2000.mdb"
  3. Dim Con As New OleDbConnection(strConnString)
  4. Dim da As New OleDbDataAdapter(sql, Con)
  5. Dim ds As New DataSet()
  6. Dim dt As DataTable
  7. Dim dsNewRow As DataRow
  8. Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(da)
  9. da.Fill(ds, "ADWarning")
  10. Con.Close()
  11. dt = ds.Tables("ADWarning")
  12. Try
  13. dsNewRow = dt.NewRow()
  14. dsNewRow("IssueDate") = Me.TextBox1.Text
  15. dsNewRow("IssueTime") = Me.TextBox2.Text
  16. dsNewRow("FcstOnsetTime") = Me.TextBox3.Text
  17. dsNewRow("FcstCldAmt") = Me.TextBox4.Text
  18. dt.Rows.Add(dsNewRow)
  19. Dim drModified As DataRow() = dt.Select(Nothing, Nothing, DataViewRowState.Added)
  20. Con.Open()
  21. ListBox1.DataSource = ds.Tables("ADWarning")
  22. ListBox1.DisplayMember = "IssueDate"
  23. da.UpdateCommand = cb.GetInsertCommand
  24. da.Update(drModified)
  25. MessageBox.Show("Database has been updated!", "Data", MessageBoxButtons.OK, MessageBoxIcon.Information)
  26. Catch eInsertException As Exception
  27. MsgBox(eInsertException.Message & eInsertException.Source)
  28. Throw eInsertException
  29. Finally
  30. Con.Close()
  31. End Try
  32.  
I get an error prompt when debugging
System.Oledb.OledbException: {"Syntax error in INSERT INTO statement."}
error code: -2147217900
error source: Microsoft JET Database Engine
Mar 19 '07 #1
1 2684
MMcCarthy
14,534 Expert Mod 8TB
VBA is very different to VB. My instinct says that you can't do it this way but I'm no expert. I'm going to ask one of the VB experts to take a look at it.

Mary
Mar 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: Uwe Range | last post by:
Hi to all! A customer of mine told me some days ago that her IT-people told her ACCESS would not be such a good idea for continuing with our project, because Access will not be continued in the...
3
by: Olivogt | last post by:
Hello, I was just puting an application on the web server but it did not work as usual... - I do develop on my notebook and move released applications to the Web server - both have Sql Server...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
6
by: Fred Geurtsen | last post by:
Question about updating a access Database Record! Normally i'm working with SQLserver, but i have to do this with access and it's not working. My error is: Operation must use an updateable query....
3
by: genojoe | last post by:
I have tried everything I can think of to move records from one Access database to another. It should not be that hard. Read on.... I have identical access mdb's. One contains data; one...
15
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions,...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
6
by: JonC | last post by:
I am developing an Access database and need to be able to print a form with various selections made as it appears on screen. The standard way of doing this would be to create a report based on the...
0
by: vacuit | last post by:
Visual Basic 2005 I want to save a copy of a datatable (that the user has changed) with a new name back to the database (Access) I have this code to save a copy with a new name to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.