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 14 8379
What database are you connecting to? Also, why do you call this line of code
readwrite.Inser tCommand = CmdBuilder.GetI nsertCommand()?
--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF http://www.apress.com/book/bookDisplay.html?bID=105
"Samy K" <sk******@hotma il.com> wrote in message
news:34******** *************** *****@phx.gbl.. . 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
Hello,
"Samy K" <sk******@hotma il.com> schrieb: 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/microsof...amework.adonet
Web interface: http://msdn.microsoft.com/newsgroups...amework.adonet
--
Herfried K. Wagner
MVP · VB Classic, VB .NET http://www.mvps.org/dotnet
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 sk******@hotmai l.com
thanks
Samy -----Original Message----- What database are you connecting to? Also, why do you
call this line of codereadwrite.Inse rtCommand = CmdBuilder.GetI nsertCommand()?
-- Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF http://www.apress.com/book/bookDisplay.html?bID=105 "Samy K" <sk******@hotma il.com> wrote in message news:34******* *************** ******@phx.gbl. .. 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
(sqlstring, 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.Text) 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
.
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/microsof...amework.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
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
Hello,
"Fergus Cooney" <fi******@tesco .net> schrieb: 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/microsof...amework.adonet.
That's exactly what I mean.
But that's far too much to copy and paste.
Too much to *download*.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
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 'inappropriatel y'. 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 misunderstandin g, 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
Hello,
"Fergus Cooney" <fi******@tesco .net> schrieb: 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 'inappropriatel y'.
No.
And sometimes it seems to be a race to see who can kick them out soonest.
I don't kick anybody out.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
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 'inappropriatel y'. 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 misunderstandin g, 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.langua ge 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.
:) Regards,
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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
|
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,...
| |
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...
|
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
|
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
|
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,...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |