473,654 Members | 3,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dataset insert into access database insert into Syntax error

6 New Member
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 2337

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

Similar topics

1
4124
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
6876
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 expression should return the 4 leftmost characters of the FilmNo
7
28742
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 (Tournament, MemberName, Score) VALUES (vtournament, vMemberName, vScore) SELECT ID, Tournament, MemberName, Score FROM Tournament WHERE (ID = @@IDENTITY);"
2
1084
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 engine cannot open the file 'D:\Ashok\WEB\SVS\Latha.mdb'. It is already opened exclusively by another user, or you need permission to view its data. I'm sure that I've closed all the instances of MS Access Database, but still this error.
1
1183
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 out why this problem is happening. Here is the code
0
1643
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 through and inserting one row at a time is very expensive. Does anyone know a fast way with low overhead to accomplish this task. I have been working in this direction (code below) however the code inserts 0 rows into the access database. ...
2
2681
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 table which has an auto number as the key. I was not sure if my connection was the problem so I tried the following select first, but it runs withput any problem: $mySQL = "SELECT * FROM Audit Where AuditID = 1089"; $resNews =...
7
2215
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 Password. Password is Date of Birth. If DOB is starting 09-08-90 or 11-01-91 is not login or DOB is starting more than 13 (13-03-91 or 28-11-91) is succefully login. 2. So I check, How? the date is print. Below code
7
2841
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 the latest patches. If I do not group the query (ie. remove aggregation) it will work. If I recall, it also works if my subquery does not have joins. I want to accomplish this with pure SQL .. I could easily write a VBA function to handle...
0
1432
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 = OpenAccessDB("MyAccessDB.mdb") or
0
8372
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.