473,835 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax Error in INSERT INTO Command

I'm having a bit of problems entering a new row to an
access database and what I would like to know is do I have
to assign certain values in my INSERT INTO SQL statement.
I have read about the commandbuilder and it said that the
insert command is automatically generated. Below is my
code. Can someone help me out into where the syntax error
is happening:

Dim readwrite As OleDb.OleDbData Adapter
Dim CmdBuilder As OleDb.OleDbComm andBuilder
Dim ds As DataSet = New DataSet()
Dim table As DataTable
Dim row As DataRow

'sqlstring is global variable with string "Select
* from inv_compt_inves t"
readwrite = New OleDb.OleDbData Adapter(sqlstri ng,
dbInventaire)
CmdBuilder = New OleDb.OleDbComm andBuilder
(readwrite)
readwrite.Inser tCommand =
CmdBuilder.GetI nsertCommand()
MsgBox(readwrit e.InsertCommand .CommandText)
Try
readwrite.Fill( ds, "inv_compt_inve st")

'output data from dataset
table = ds.Tables.Item( 0)
If table.Rows.Coun t <> 0 Then

'Enter new records
If newdataentry = True Then
row = table.NewRow()
row("Date d'acquisition") = CDate
(TextBox2.Text)
row("Num de Compte") = CInt
(TextBox3.Text)
row("Designatio n de l'article") =
TextBox4.Text
row("Quantite") = CInt(TextBox5.T ext)
row("Fournisseu r") = TextBox6.Text
row("Num de la facture") =
TextBox7.Text
row("Marque") = TextBox8.Text
row("Localisati on") = TextBox9.Text
table.Rows.Add( row)

'Update the database table
readwrite.Updat e
(ds, "inv_compt_inve st") 'The exception gets triggered
here through debugging
newdataentry = False
Else
MsgBox("Need to enter new data to save
to Database")
End If
End If
Catch ex As Exception
MsgBox(ex.Messa ge)
End Try

thanks,

Sam
Nov 20 '05
14 8380
Cor
Herfried,
Unfortanaly I did first answer Fergus and then read yours and Charles
answer.

Mhm... In the German language, "please" ("bitte") is considered very
friendly and not rude.

I did suspect that, see my message
:-)
Cor
Nov 20 '05 #11
Cor
Charles,
Unfortanaly I did first answer Fergus his message and than read the answers
from Herfried and You.
I do realise though, that it's probably the
case that whilst it is easy for people whose first language is English to be verbose, it is less so for people for whom English is not their first
language.

I did write it without first looking at your message, so we are thinking the
same about that.
:-)
Cor
Nov 20 '05 #12
Hi Cor,

I posted this days ago, but to your personal email by mistake. Then I was
off for a few days helping my sister out. On return I discovered my message
returned to me. Here it is again - old news now but never mind. :-)
=============== =============== ====
Hi Cor,

I think this issue has been thoroughly covered but I want to respond to
you and thank you.

|| My idea was that there are a lot of people visiting this newsgroup,
|| for whom the more abstract English is not so easy to read [rephrased].

As said elsewhere, this is a good point for me to bear in mind. My English
ranges from gutter-speak (in off-topics) to fairly 'high brow' (abstract) -
with a fair smattering of idiom and slang. It would be interesting to know how
often I 'miss my target' because of this.

|| .. but that can be the difference in languages.
|| "Please go" is maybe in the English language much more
|| tyrrany than in German.
|| The word Please in this sentence is in my eyes too very bad
|| (in Dutch it is rude to use it in this way) I thought it is in English
|| the same. But maybe Herfried and Armin suspect that it is polite.

I agree. In English it is a polite word that can be used for exactly the
opposite effect. An example of that it the way I asked Stephany to
(effectively) "Please keep your nose out of our business". If you heard the
tone of voice that goes with <that 'please'> you'd not think I was being
polite!

|| ... if there is a better place, we have to tell them that.

I like your idea of giving it some time so that those with an answer can
give it. And then, if there is no replay, or perhaps in addition, a
redirection can be given. It is partly the rapidity which has caused me
distress.

|| And sometimes it is so out of topic, that it is better not to help ...
|| Giving long Helps on VB6 or Powerpoint questions makes that
|| this group becomes visited by a lot of people from there.
|| And after a while the people who have VB.net questions can not
|| find that questions anymore in the Google VB.net group.

This is a very good point. I want to help whoever I can, but there <is>
the possibility of this newsgroup getting a reputation as being generalist.
[Maybe I should move to dotnet.general but I like the people here. And the
questions, actually]. I have no sensible solution to this issue. Perhaps we
could issue 'tickets' to people - One OT question per email address. Any more
OT's and they get "The Severe Redirection"!! ;-) **

But then again, I'm not so sure that it would be a disaster. I would hope
that a well phrased Google search would only pull out relevant posts. I think
that people who visit for answers are of two main types - those with a query
and once they've got it they're off. They aren't particularly interested in
other posts, and those who just browse. Some of the latter may find cause for
concern.

|| Other points.

We are much in agreement. As I implied elsewhere, my Irish blood was
stirred up by the confrontations with Jack and Stephany. Thank you for
accepting my views and expressing them without the annoyance that I was
feeling.

Cor, you've been very good, very conciliatory*. You show great care for
us. :-D

|| > When you're dealing with a text-only communication - no faces,
|| > no expressions, no gestures, no tone of voice - it is important to
|| > be very careful how you express yourself. That's why I use :-)
|| > so much. Whenever there is even a hint of the other person
|| > misunderstandin g, it is best to be clear. To soften,
|| > where possible.
||
|| I have not trained as a psychologist, but this is what I say for
|| year and that started with the begin of e-mail

Some people are naturals. If you ever get fed up with programming, you
might take up counselling! ;-)

Regards,
Fergus

=============== =======
**
The Severe Redirection
"You've had your OT question - now GET LOST!!
And <don't> come back unless you've got a VB.NET question!!"

* conciliatory - [from 'to conciliate; 'reconciliation ']. In this instance -
one who seeks good will for all, and acceptance on all sides.
Nov 20 '05 #13
Cor
Fergus,
You understand it, I was curious about your answer on this message.
I've seen Herfried started to do like we did talk about and Armin in a way
too.
You can see Armin takes more time to write text like he does in the German
newsgroup.
Thanks for your answer,
Cor
Nov 20 '05 #14
Hello,

"Cor" <no*@non.com> schrieb:
You understand it, I was curious about your answer on
this message. I've seen Herfried started to do like we did
talk about and Armin in a way too.


I will use the text suggested by Fergus...

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3243
by: Donald Canton | last post by:
Hi, I'm using Bjarne's book to learn C++ and am stuck on the Calc program in Section 6. Everything works fine except when I try to use istringstream to parse a token from the command line. I thought I followed his instructions on page 118 correctly, but I can't get it to compile without syntax errors in the get_token() function. The whole program follows with the four syntax errors flagged with the text "// SYNTAX ERROR". Thanks in...
8
2094
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is, I've been playing with Qt in KDE on a Slackware 10.0 system, and following their cookbook exercises, and everything's working, and I have no clue what the code is doing, i.e.. how do I connect my brain to the ascii in the files to the stuff on...
4
18062
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out on me for some reason. The Summary field is pulled from a Rich Text Editor that allows HTML formatting and appears to be the culprit, but I just can't seem to figure out why. Any guidance is greatly appreciated. I'm connecting to an Access...
3
2505
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92
8
2228
by: Kevin Murphy | last post by:
Using PG 7.4.3 on Mac OS X 10.2.8, the following "insert into ... select ..." statement completed and then announced a syntax error, which seems bizarre. (Don't be confused by the fact that the two tables referred to (public.identifiers and original.identifiers) have slightly different column names.) egenome_dev=# \!cat /Users/murphy/cvs/egora/sql/data_port/port_identifiers.sql INSERT INTO public.identifiers (element_id, name, source,...
2
4817
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and sql server is my backend server. This error occured whenever i step through and when it reaches rs.update it jux hangs down there and thereafter it shwn the aforementioned error. I am using the RecordSet properties to add the values. Can I use...
0
8337
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically generated.Iam not able fix the error. Iam working with Visual Web Developer-2005 Express Edition
4
3234
by: cluce | last post by:
I am getting a syntax error but I cant seem to spot it. need help with this. Its when I click the save button that fires my SQL UPDATE query. thansk in advance 'module level declarations Dim rsNames As ADODB.Recordset Dim cnDb As ADODB.Connection Dim strConnection As String Dim blnAddMode As Boolean
1
2707
by: gilesy | last post by:
Hi, I have a ploblem with an insert statement using an access database, I have the same code with a sql database which works but it doesn't seem to work on access. Could someone please help. For i = 0 To dg.Rows.Count - 1 Main.Command.CommandText = "INSERT INTO Diary (Date1, Time, Appointment) VALUES (?, ?, ?)" Dim param1 As System.Data.OleDb.OleDbParameter = New System.Data.OleDb.OleDbParameter("Date1", dg(1,...
3
5240
by: gilesy | last post by:
Hi, I have a ploblem with an insert statement using an access database, I have the same code with a sql database which works but it doesn't seem to work on access. Could someone please help. For i = 0 To dg.Rows.Count - 1 Main.Command.CommandText = "INSERT INTO Diary (Date1, Time, Appointment) VALUES (?, ?, ?)" Dim param1 As System.Data.OleDb.OleDbParameter = New System.Data.OleDb.OleDbParameter("Date1", dg(1, i).Value) Dim param2 As...
0
9652
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
10812
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
10523
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
10561
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
10235
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
7766
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...
0
6966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3089
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.