473,320 Members | 2,111 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,320 software developers and data experts.

Dataset insert into access database insert into Syntax error

Hello,

I have been working with this problem now for several days. I can delete and Update my data but I can not get it to insert a new record. I receive the syntax error insert into. I am not using any reserved words and I have not been able to find my answer googling like crazy. Any help would be greatly appreciated. below is the code that seems to give me the problem.

Expand|Select|Wrap|Line Numbers
  1.  
  2. ElseIf NEWMODE = True Then 
  3.  
  4.             Dim oAdapter As OleDb.OleDbDataAdapter 
  5.             Dim cb As OleDb.OleDbCommandBuilder 
  6.             Dim dr As DataRow 
  7.             Dim ds As DataSet 
  8.             Dim strSQL As String = "SELECT * FROM [Private Criminal Complaints 2]" 
  9.  
  10.             ds = New DataSet() 
  11.             oAdapter = New OleDb.OleDbDataAdapter(strSQL, Con) 
  12.             oAdapter.Fill(ds) 'Execute the Query and grab results 
  13.  
  14.             Try 
  15.                 dr = ds.Tables(0).NewRow() 
  16.  
  17.                 dr.BeginEdit() 
  18.  
  19.                 dr.Item("CompLastName") = txtCLname.Text 
  20.                 dr.Item("CompFirstName") = txtCFname.Text 
  21.                 dr.Item("DefLastName") = txtDLname.Text 
  22.                 dr.Item("DefFirstName") = txtDFname.Text 
  23.                 dr.Item("NameADA") = txtADA.Text 
  24.                 dr.Item("Detective") = txtDet.Text 
  25.                 dr.Item("Disposition") = txtDisposition.Text 
  26.                 dr.Item("ReasonFiled") = txtreason.Text 
  27.                 dr.Item("DateFiled") = txtDate.Text 
  28.  
  29.  
  30.                 dr.EndEdit() 
  31.  
  32.                 ds.Tables(0).Rows.Add(dr) 
  33.                 cb = New OleDb.OleDbCommandBuilder(oAdapter) 
  34.                 oAdapter.InsertCommand = cb.GetInsertCommand() 
  35.                 oAdapter.Update(ds) 
  36.                 ds.AcceptChanges() 
  37.  
  38.                 MessageBox.Show("Insert Successful") 
  39.                 NEWMODE = False 'Add success, end NEWMODE 
  40.                 ClearTextBoxes() 'Add Success, clean up textboxes 
  41.             Catch ex As Exception 
  42.                 MessageBox.Show(ex.Message) 
  43.  
  44.             Finally 
  45.                 Con.Close() 
  46.             End Try 
  47.  
  48.         Else 'Its not Editmode or Newmode 
  49.             'Do nothing 
  50.         End If 
  51.  
  52.         RefreshLV() 'Regardless of what happens, might as well refresh the data in the Listview 
  53.     End Sub 
  54.  
Dec 6 '10 #1
0 2302

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

Similar topics

1
by: Azel | last post by:
Hi, I am trying to learn ADO.net and I keep running into problems trying to insert data into my Access Database: data.mdb. here is my code: <code> // Database Variables
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
7
by: Cindy H | last post by:
Hi I'm having a problem getting the insert statement correct for an Access table I'm using. The Access table uses an autonumber for the primary key. I have tried this: INSERT INTO Tournaments...
2
by: ashokingroups | last post by:
Hi to all :) Goodmorning, Please take a look on my problem. I am trying to connect from ASP.Net application to MS Access Database. The following error is coming: The Microsoft Jet database...
1
by: blazinjoe1 | last post by:
Hey guys, I have tryed something new code with updating an access database but the error Syntax error in UPDATE statement occurs every time i try to update. Can some please help me figure...
0
by: SL Culby | last post by:
Hello everyone, I have a project where I pull SQL Server data put it into a dataset and now I have to put the dataset data into an Access Database. The dataset currently is over 2000 row, so looping...
2
by: kerriejones | last post by:
I am a bit rusty with my php, but I need to move some code on to a new website and coming upon a lot of problems. This one I can not solvefor the life of me. I am trying to insert a record into a...
7
by: shivasusan | last post by:
Hello Friend! I am new for ASP. Database is Microsoft Access. So pls help me..... My problem is --- 1. In login page, two text boxs. first textbox is username & second textbox is...
7
by: Yesurbius | last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all...
0
by: Tom Loder | last post by:
I want to create a dataset at runtime from an access database (or another database) but at designtime I don't know the structure. Ideally what I want to do is: Dim ds as new DataSet =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.