Syntax Error in INSERT INTO Command

S

Samy K

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.OleDbDataAdapter
Dim CmdBuilder As OleDb.OleDbCommandBuilder
Dim ds As DataSet = New DataSet()
Dim table As DataTable
Dim row As DataRow

'sqlstring is global variable with string "Select
* from inv_compt_invest"
readwrite = New OleDb.OleDbDataAdapter(sqlstring,
dbInventaire)
CmdBuilder = New OleDb.OleDbCommandBuilder
(readwrite)
readwrite.InsertCommand =
CmdBuilder.GetInsertCommand()
MsgBox(readwrite.InsertCommand.CommandText)
Try
readwrite.Fill(ds, "inv_compt_invest")

'output data from dataset
table = ds.Tables.Item(0)
If table.Rows.Count <> 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("Designation de l'article") =
TextBox4.Text
row("Quantite") = CInt(TextBox5.Text)
row("Fournisseur") = TextBox6.Text
row("Num de la facture") =
TextBox7.Text
row("Marque") = TextBox8.Text
row("Localisation") = TextBox9.Text
table.Rows.Add(row)

'Update the database table
readwrite.Update
(ds, "inv_compt_invest") '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.Message)
End Try

thanks,

Sam
 
C

CT

What database are you connecting to? Also, why do you call this line of code
readwrite.InsertCommand = CmdBuilder.GetInsertCommand()?
 
H

Herfried K. Wagner [MVP]

Hello,

Samy K said:
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:

This is a VB.NET language group. Please turn to the ADO.NET newsgroup:

news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet

Web interface:

http://msdn.microsoft.com/newsgroup...roup=microsoft.public.dotnet.framework.adonet
 
S

Samy K

I'm connecting to an access database locally on my
computer. I am using the CommandBuilder because I read
that it provides a mechanism to automatically generate
commands used to facilitate the updates made in an
OleDbDataSet to the corresponding table. If you give me
some points as to where the problem is occuring and why
it occurs that would be appreciated. Unfortunately I've
been told that this is not the right group to post. My
email to reply is (e-mail address removed)

thanks

Samy
 
F

Fergus Cooney

Hi Samy,

You have to forgive Herfried - he doesn't mean to sound like a policeman..
It's just that his English is a bit terse at times.

When he says

|| This is a VB.NET language group.
|| Please turn to the ADO.NET newsgroup:",

what he really means is

Welcome to the languages.vb newsgroup. This newsgroup is really intended
for the VB.NET language and related issues. There are specialised newsgroups
for database queries and I feel you will get the best support possible by
going to one of these. The ADO.NET newsgroup can be found at
news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet. Go ahead
and post your question there. :)

But that's far too much to copy and paste.

Now that you're here, though, and someone is responding to you, you might
as well continue.

Regards,
Fergus
 
C

Cor

Fergus,
Has it really to be that long.
Maybe you can find something in between, than Herfried can copy that in that
big archive of him.
:)
Cor
 
H

Herfried K. Wagner [MVP]

Hello,

Fergus Cooney said:
You have to forgive Herfried - he doesn't mean to sound like
a policeman..
It's just that his English is a bit terse at times.

When he says

|| This is a VB.NET language group.
|| Please turn to the ADO.NET newsgroup:",

what he really means is

Welcome to the languages.vb newsgroup. This newsgroup is
really intended for the VB.NET language and related issues.
There are specialised newsgroups for database queries and I
feel you will get the best support possible by going to one of
these. The ADO.NET newsgroup can be found at
news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet.

That's exactly what I mean.
But that's far too much to copy and paste.

Too much to *download*.
 
F

Fergus Cooney

Hi Cor,

I copied that from one of the advisers in the dotnet.academic group. When
I first read it I thought that it was very well worded and full of
sensitivity. I don't think it's too long, myself. Remember, each person coming
here for the first time will be reading that as if it is a conversation to
them. They have the time to read a few sentences when it is politely telling
them that their presence is welcomed - but that it would be better for them to
try elsewhere.

<rant>

Unfortunately, I do believe that Herfried's and Armin's "This is vb.net..
Please go" iis actually short to the point of being rude. It implies that our
visitors are wrong to be here - not that they are welcome but we are not the
best people for them. To me it is better than "Not here. Go away", but not
hugely so.

I find reading the "This is vb.net.. Please go" messages more of a chore
than others do reading OT messages. This is simply because there have been so
many times when I or someone else <has> had an answer to the query. So what if
this is the wrong area? Maybe I or someone can help. Let us do so. We should
be telling visitors that if they get no response then elsewhere may be better
<for them>. We shouldn't be implying that they are trespassing on <our> sacred
ground.

It sometimes seems to me that Herfried and Armin are just waiting so that
they can jump on people who wander in here 'inappropriately'. And sometimes it
seems to be a race to see who can kick them out soonest.

Cor, I have training as a psychologist and therapist, so I am always
looking to be aware of how people will perceive what I'm typing to them. 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 misunderstanding, it is best to be clear. To soften, where
possible.

Sorry to get so heavy on this topic, Cor, but my feelings about this have
been getting stronger and stronger. I'm taking the opportunity to tell you, as
it allows me to say what I feel without having to address Herfried and Armin
directly. I've been getting close to doing so, but I like and admire them
both, and don't want to cause bad feeling. I'm sure that the rudeness that I
perceive isn't their intention. But I am certain that it is ignorance.

You can say that I'm being over sensitive. I <am> sensitive when it comes
to these sort of issues (but, hey, that's part of being a therapist). Many
times I'm probably being more careful than necessary. But it's the same
principle as in programming. How many error checks and exception handlers do
you insert 'just in case' - for errors you'd never really expect? That's
considered good, robust programming. Ditto with using more words than fewer
to communicate with friendliness.

</rant>

Thanks for listening to all this. :)

Regards,
Fergus
 
F

Fergus Cooney

Hi Herfried,

I thinking that you'll have read my message to Cor first.

|| Too much to *download*.

My guideline would be: Don't protect their time - protect their feelings,
as these are much more important.

Regards,
Fergus
 
H

Herfried K. Wagner [MVP]

Hello,

Fergus Cooney said:
My guideline would be: Don't protect their time - protect their feelings,
as these are much more important.

This is a technical ng, everything should be written as short as
possible. Nobody there has time to read really long stories. Short <>
unfriendly!

;-)
 
C

Charles Law

Hey Fergus, I'm over here.

This looks like the perfect place for me to add a few words ...

Some people may remember one of my first posts when I stumbled in here a few
months ago, and unintentionally abused Herfried for what I think Fergus has
just put well into words. My first impression was that some responses were
terse and unhelpful. Saying so at the time brought me under fire myself, and
again I apologise for the way in which I kicked off.

Having been following this newsgroup for a while now, I realise that the
regulars here are all well intentioned people who provide a great deal of
assistance to many people, myself included, it's just that first impressions
may belie the truth of that. 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.

Anyway, thanks all.

Charles
[Now, Fergus, about this other little problem I'm having ...]
 
F

Fergus Cooney

Hi Herfried,

|| This is a technical ng, everything should be written as
|| short as possible.

I'm sorry but I can't agree. I thinks that that's a 'technical' attitude.

Some of the links that you give are to documents with much wordiness. One
example being the two long articles on garbage collection. These, despite
their length, have been well recieved in both this and the csharp newsgroups.


|| Nobody here has time to read really long stories.

People will read anything of any length if it is relevant to them. If you
can add an explaination of some topic that re-explains what the MSDN docs say,
you may do a whole heap of good. With all my experience I still find much of
the MSDN documentation obtuse and/or full of gaps. Giving someone a simplified
version of a topic is going to consume words but it may make it that much
easier to understand the official documentation. In general, the amount of
time that a person will spend on any topic will be extended if that topic
contains humour and/or promotes goodwill, so long as it remains sufficiently
relevant.

|| Nobody here has time to read really long stories.

Herfried doesn't have time to write longer answers?? [But when you have,
I've thought it was worth it]


|| Short <> unfriendly!

"Short <> friendly" is not up to you to define. It's up to the person who
you give the message to. It's fairly hard to misunderstand friendliness as
anything other than what it is (unless you tend towards paranoia, or unless
it's too jokey and is seen as flippant). It's only too easy to misunderstand
terseness. Not everyone will, of course. But <some> will. Some people will
'turn to xyz newsgroup' thinking unkind or sad thought about having made the
'mistake' of coming here first. Charles' response to my lengthy post is one
example. How many might there be out there that will never be expressed ?


I hope you don't think I'm telling you off in the way that I did with Jack
and Stephany. I have little respect for them and much for you, Herfried. But I
do speak strongly, and that may hurt your feelings. If this is the case I
apologise.

This issue is very important to me. It's true that it is a mixture of
personal ethics and sensitivities, however I believe there are also some sound
reasons behind my views. I like people who come into my life (eg, in this
newsgroup) to go away not just satisfied that they got something useful, or
had some blockage removed, etc, but to go away <happy> with the encounter.
Glad that they came <here>.

This is not life and death. It's not essential. And, certainly, making
people happy is not important to everyone (is it Jack? :)). But it is to me.

Regards,
Fergus
 
H

Herfried K. Wagner [MVP]

Hello,

Fergus Cooney said:
Remember, each person coming here for the first time will
be reading that as if it is a conversation to them. They have the
time to read a few sentences when it is politely telling them that
their presence is welcomed - but that it would be better for them to
try elsewhere.

That's theory.
Unfortunately, I do believe that Herfried's and Armin's
"This is vb.net.. Please go" iis actually short to the point
of being rude.

Mhm... In the German language, "please" ("bitte") is considered very
friendly and not rude.
It implies that our visitors are wrong to be here -

They _are_ wrong in this ng.
not that they are welcome but we are not the best people
for them. To me it is better than "Not here. Go away", but not
hugely so.
LOL

I find reading the "This is vb.net.. Please go" messages more
of a chore than others do reading OT messages. This is simply
because there have been so many times when I or someone
else <has> had an answer to the query. So what if this is the
wrong area?

If it's in the wrong ng, I tell the OP that he should post to a
more-suitable ng. Maybe this will prevent future postings in the wrong
ng.
Maybe I or someone can help. Let us do so.
Yep.

We should be telling visitors that if they get no response then
elsewhere may be better <for them>. We shouldn't be implying that
they are trespassing on <our> sacred ground.

That's _your_ interpretation. If you have a look at the replies to my
"go to..." postings, you will see that some posters say "thank you for
the hint" or something like that.
It sometimes seems to me that Herfried and Armin are just waiting
so that they can jump on people who wander in here 'inappropriately'.
No.

And sometimes it seems to be a race to see who can kick
them out soonest.

I don't kick anybody out.
 
C

Cor

Hi Fergus,
I do it in Herfried style this time.
I copied that from one of the advisers in the dotnet.academic group. When
I first read it I thought that it was very well worded and full of
sensitivity. I don't think it's too long, myself. Remember, each person coming
here for the first time will be reading that as if it is a conversation to
them. They have the time to read a few sentences when it is politely telling
them that their presence is welcomed - but that it would be better for them to
try elsewhere.
First of all we agree totaly.
My Idea was that there are a lot of people visiting this newsgroup, for who
is the not abstract English not so easy to read. I think that we have to
keep that in mind. (Although it is normaly not a problem, they have the
documentation to read too and that is often in bad English).
Therefore I think it hat to be polite but short to the subject. Therefore
was my thought such a sentence can be best done by someone who is a real
Englishman. But maybe you can make it and Herfried, Armin and I can look it
over. Think about your sentence more bellow about the communication aspect.
Unfortunately, I do believe that Herfried's and Armin's "This is vb.net..
Please go" iis actually short to the point of being rude. It implies that our
visitors are wrong to be here - not that they are welcome but we are not the
best people for them. To me it is better than "Not here. Go away", but not
hugely so.

Yes 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 find reading the "This is vb.net.. Please go" messages more of a chore
than others do reading OT messages. This is simply because there have been so
many times when I or someone else <has> had an answer to the query. So what if
this is the wrong area? Maybe I or someone can help. Let us do so. We should
be telling visitors that if they get no response then elsewhere may be better
<for them>. We shouldn't be implying that they are trespassing on <our> sacred
ground.

Agree, but if there is a better place, we have too tell them that. And
sometimes it is so out of topic, that it is better not to help I think.
And then one of your so called Microsofties kickes on it in this newsgroup
and start helping about HTML, VB6 or IIS. :-(
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.
I think it has to do with good sence.
It sometimes seems to me that Herfried and Armin are just waiting so that
they can jump on people who wander in here 'inappropriately'. And sometimes it
seems to be a race to see who can kick them out soonest.
I sometimes too get that Idea, but not only Herfried and Armin.
Refering to JavaScript in a VB.net question means that they get a "Please
go" and the strangest is that when people only use C# in the same sentence
they will be direct helped.
Cor, I have training as a psychologist and therapist, so I am always
looking to be aware of how people will perceive what I'm typing to them. 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 misunderstanding, it is best to be clear. To soften, where
possible.

I have not trained as a psycholist, but this is what I say for year and that
started with the begin of e-mail.
Sorry to get so heavy on this topic, Cor, but my feelings about this have
been getting stronger and stronger. I'm taking the opportunity to tell you, as
it allows me to say what I feel without having to address Herfried and Armin
directly. I've been getting close to doing so, but I like and admire them
both, and don't want to cause bad feeling. I'm sure that the rudeness that I
perceive isn't their intention. But I am certain that it is ignorance.

I think that this very on Topic, this is how we behave our self in this
newsgroup and not in a Mainthread.
I do absolute not think that it is for Herfried and Armin to be rude. Take a
look at the de.vbnet.language group.
That is totaly different but what Herfried did write. That is a very
diciplined group. But that has maybe to do with the way people from German
acts in oposite from people from cities like London and Amsterdam. People
from major cities from the world acts in a different way than people who are
not from those.
You can say that I'm being over sensitive. I <am> sensitive when it comes
to these sort of issues (but, hey, that's part of being a therapist). Many
times I'm probably being more careful than necessary. But it's the same
principle as in programming. How many error checks and exception handlers do
you insert 'just in case' - for errors you'd never really expect? That's
considered good, robust programming. Ditto with using more words than fewer
to communicate with friendliness.
I agree totaly, but is not always true I think, keep in mind that not
everybody understand non abstract English in this newsgroup.
Although reading is of course more easy than writing. Everybody who realy
makes programmes is sticked too use the English language for documentation.I read most of your messages.
And thank you for reading my answers.
:)
 
C

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
 
C

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
 
F

Fergus Cooney

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
|| > misunderstanding, 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.
 
C

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
 
H

Herfried K. Wagner [MVP]

Hello,

Cor said:
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...

;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top