473,486 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

command object vb2005 ado

Rob
hi all,

i'am working on a database based on VB2005 using ado.
iv a combobox on mine form, which i fill with a datareader and command. If
i've new data in my cbo.text and textfield , i want this to save the new
values into mine accesstable.

i have already a connection to mine db to fill the cbo with value.
ive tried with as followed:
'******************
dim newsql as string
'vrTxtfield1 and vrcbotext are two variabels which containes the new data i
need to store.
newsql = "INSERT INTO tbltest(field1, field2)VALUES (" & vrTxtfield1 & "," &
vrcbotext & ")"
Dim cmmdsql As New OleDb.OleDbCommand(newsql , cn)
cmmdsql.ExecuteNonQuery()
'**************
Which command do i need to achieve this ?

regards, Rob
Jun 27 '08 #1
6 811
Rob,

I do this in this message so be aware of errors.

\\\
'vrTxtfield1 and vrcbotext are two variabels which containes the new data i
need to store.
dim newsql as string = "INSERT INTO tbltest(field1, field2)VALUES (@Param1,
@Param2)"
Dim cmdsql As New OleDb.OleDbCommand(newsql , cn)
cmdSql.Parameters.Add("@Param1",vrTxtfield1)
cmdSql.Parameters.Add("@Param2",vrcbotext )
cn.Open
cmmdsql.ExecuteNonQuery()
cn.Close
///

I cannot see what database you use, as that is a version of SQL server then
you can use better SQLClient instead of OleDB, in a real version you should
also add error trapping by a try catch block.
Better newsgroups for you are probably
microsoft.public.dotnet.Framework.Adonet
microsoft.public.dotnet.languages.vb
or maybe the very inactive newsgroup
microsoft.public.nl.devtools

Succes

Cor

Jun 27 '08 #2
Rob
hi Cord
The database is an access database.

I give it a try in the newgroup you propose.
If you get the answer anyway, don't hasitate to replay.
Kindley regards, Rob
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:E6**********************************@microsof t.com...
Rob,

I do this in this message so be aware of errors.

\\\
'vrTxtfield1 and vrcbotext are two variabels which containes the new data
i need to store.
dim newsql as string = "INSERT INTO tbltest(field1, field2)VALUES
(@Param1, @Param2)"
Dim cmdsql As New OleDb.OleDbCommand(newsql , cn)
cmdSql.Parameters.Add("@Param1",vrTxtfield1)
cmdSql.Parameters.Add("@Param2",vrcbotext )
cn.Open
cmmdsql.ExecuteNonQuery()
cn.Close
///

I cannot see what database you use, as that is a version of SQL server
then you can use better SQLClient instead of OleDB, in a real version you
should also add error trapping by a try catch block.
Better newsgroups for you are probably
microsoft.public.dotnet.Framework.Adonet
microsoft.public.dotnet.languages.vb
or maybe the very inactive newsgroup
microsoft.public.nl.devtools

Succes

Cor

Jun 27 '08 #3
Hi Rob,

Did you look at the code I made?

:-)

Cor

"Rob" <RO*@sdmlfk.nlschreef in bericht
news:uQ**************@TK2MSFTNGP02.phx.gbl...
hi Cord
The database is an access database.

I give it a try in the newgroup you propose.
If you get the answer anyway, don't hasitate to replay.
Kindley regards, Rob
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:E6**********************************@microsof t.com...
>Rob,

I do this in this message so be aware of errors.

\\\
'vrTxtfield1 and vrcbotext are two variabels which containes the new data
i need to store.
dim newsql as string = "INSERT INTO tbltest(field1, field2)VALUES
(@Param1, @Param2)"
Dim cmdsql As New OleDb.OleDbCommand(newsql , cn)
cmdSql.Parameters.Add("@Param1",vrTxtfield1)
cmdSql.Parameters.Add("@Param2",vrcbotext )
cn.Open
cmmdsql.ExecuteNonQuery()
cn.Close
///

I cannot see what database you use, as that is a version of SQL server
then you can use better SQLClient instead of OleDB, in a real version you
should also add error trapping by a try catch block.
Better newsgroups for you are probably
microsoft.public.dotnet.Framework.Adonet
microsoft.public.dotnet.languages.vb
or maybe the very inactive newsgroup
microsoft.public.nl.devtools

Succes

Cor

Jun 27 '08 #4
Rob
hi again,
yes , of course id , but he struggles
'---cmdSql.Parameters.Add("field1", vrTxtfield1)
cmdSql.Parameters.Add("field2", vrcbotext )

sqlPCGem.ExecuteNonQuery()

I cannot get to put the parameter after the cmdSql. i can't see the
parameteroption in the list who's available fo the sqlcmd. and in the
errorsection is written that parameter is not a member of the string.

Also i get error on the last line said he is not a member of a string.

regards, rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:5E**********************************@microsof t.com...
Hi Rob,

Did you look at the code I made?

:-)

Cor

"Rob" <RO*@sdmlfk.nlschreef in bericht
news:uQ**************@TK2MSFTNGP02.phx.gbl...
>hi Cord
The database is an access database.

I give it a try in the newgroup you propose.
If you get the answer anyway, don't hasitate to replay.
Kindley regards, Rob
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:E6**********************************@microso ft.com...
>>Rob,

I do this in this message so be aware of errors.

\\\
'vrTxtfield1 and vrcbotext are two variabels which containes the new
data i need to store.
dim newsql as string = "INSERT INTO tbltest(field1, field2)VALUES
(@Param1, @Param2)"
Dim cmdsql As New OleDb.OleDbCommand(newsql , cn)
cmdSql.Parameters.Add("@Param1",vrTxtfield1)
cmdSql.Parameters.Add("@Param2",vrcbotext )
cn.Open
cmmdsql.ExecuteNonQuery()
cn.Close
///

I cannot see what database you use, as that is a version of SQL server
then you can use better SQLClient instead of OleDB, in a real version
you should also add error trapping by a try catch block.
Better newsgroups for you are probably
microsoft.public.dotnet.Framework.Adonet
microsoft.public.dotnet.languages.vb
or maybe the very inactive newsgroup
microsoft.public.nl.devtools

Succes

Cor


Jun 27 '08 #5
Hi Rob,

Sorry, I wrote it in this message, the adding of a parameter should be

\\\

cmdSql.Parameters.Add(New OleDb.OleDbParameter("@Param1", "vrTxtfield1"))

///

Cor

"Rob" <RO*@sdmlfk.nlschreef in bericht
news:uc****************@TK2MSFTNGP04.phx.gbl...
hi again,
yes , of course id , but he struggles
'---cmdSql.Parameters.Add("field1", vrTxtfield1)
cmdSql.Parameters.Add("field2", vrcbotext )

sqlPCGem.ExecuteNonQuery()

I cannot get to put the parameter after the cmdSql. i can't see the
parameteroption in the list who's available fo the sqlcmd. and in the
errorsection is written that parameter is not a member of the string.

Also i get error on the last line said he is not a member of a string.

regards, rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:5E**********************************@microsof t.com...
>Hi Rob,

Did you look at the code I made?

:-)

Cor

"Rob" <RO*@sdmlfk.nlschreef in bericht
news:uQ**************@TK2MSFTNGP02.phx.gbl...
>>hi Cord
The database is an access database.

I give it a try in the newgroup you propose.
If you get the answer anyway, don't hasitate to replay.
Kindley regards, Rob
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:E6**********************************@micros oft.com...
Rob,

I do this in this message so be aware of errors.

\\\
'vrTxtfield1 and vrcbotext are two variabels which containes the new
data i need to store.
dim newsql as string = "INSERT INTO tbltest(field1, field2)VALUES
(@Param1, @Param2)"
Dim cmdsql As New OleDb.OleDbCommand(newsql , cn)
cmdSql.Parameters.Add("@Param1",vrTxtfield1)
cmdSql.Parameters.Add("@Param2",vrcbotext )
cn.Open
cmmdsql.ExecuteNonQuery()
cn.Close
///

I cannot see what database you use, as that is a version of SQL server
then you can use better SQLClient instead of OleDB, in a real version
you should also add error trapping by a try catch block.
Better newsgroups for you are probably
microsoft.public.dotnet.Framework.Adonet
microsoft.public.dotnet.languages.vb
or maybe the very inactive newsgroup
microsoft.public.nl.devtools

Succes

Cor


Jun 27 '08 #6
Rob
Hi Cor,

Finaly , it works great
Many Thanks for yor help, Rob
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:B2**********************************@microsof t.com...
Hi Rob,

Sorry, I wrote it in this message, the adding of a parameter should be

\\\

cmdSql.Parameters.Add(New OleDb.OleDbParameter("@Param1", "vrTxtfield1"))

///

Cor

"Rob" <RO*@sdmlfk.nlschreef in bericht
news:uc****************@TK2MSFTNGP04.phx.gbl...
>hi again,
yes , of course id , but he struggles
'---cmdSql.Parameters.Add("field1", vrTxtfield1)
cmdSql.Parameters.Add("field2", vrcbotext )

sqlPCGem.ExecuteNonQuery()

I cannot get to put the parameter after the cmdSql. i can't see the
parameteroption in the list who's available fo the sqlcmd. and in the
errorsection is written that parameter is not a member of the string.

Also i get error on the last line said he is not a member of a string.

regards, rob

"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:5E**********************************@microso ft.com...
>>Hi Rob,

Did you look at the code I made?

:-)

Cor

"Rob" <RO*@sdmlfk.nlschreef in bericht
news:uQ**************@TK2MSFTNGP02.phx.gbl...
hi Cord
The database is an access database.

I give it a try in the newgroup you propose.
If you get the answer anyway, don't hasitate to replay.
Kindley regards, Rob
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:E6**********************************@micro soft.com...
Rob,
>
I do this in this message so be aware of errors.
>
\\\
'vrTxtfield1 and vrcbotext are two variabels which containes the new
data i need to store.
dim newsql as string = "INSERT INTO tbltest(field1, field2)VALUES
(@Param1, @Param2)"
Dim cmdsql As New OleDb.OleDbCommand(newsql , cn)
cmdSql.Parameters.Add("@Param1",vrTxtfield1)
cmdSql.Parameters.Add("@Param2",vrcbotext )
cn.Open
cmmdsql.ExecuteNonQuery()
cn.Close
///
>
I cannot see what database you use, as that is a version of SQL server
then you can use better SQLClient instead of OleDB, in a real version
you should also add error trapping by a try catch block.
>
>
Better newsgroups for you are probably
microsoft.public.dotnet.Framework.Adonet
microsoft.public.dotnet.languages.vb
or maybe the very inactive newsgroup
microsoft.public.nl.devtools
>
Succes
>
Cor


Jun 27 '08 #7

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

Similar topics

2
17190
by: John | last post by:
Hi: I a newbie to VB, though I have a fair bit of experience with other languages. My problem is that I need to access the command. I have tried using: Private Sub ReportViewer_Load(ByVal...
5
3692
by: Chris Devol | last post by:
My dial-up connection sometimes hangs up and has to re-connect. The VB2005 installer/downloader apparently doesn't know how to resume when the connection is re-established. It just aborts! I've...
3
1861
by: Diarmuid | last post by:
I have the MS book, introducing Microsoft Visual Basic 2005 for Developers. No sample code comes with it.The location according to the book is http://msdn.microsoft.com/vbasic/VB6Migration but I...
2
1302
by: Jerry Spence1 | last post by:
1. Is there a more suitable, dedicated newsfeed for VB2005 yet? 2. I'm confused as to which version to get. I work for a small company and we will just need VB2005 on my PC. Therefore that tends...
3
4822
by: Michael Roebuck | last post by:
Hi all I'm very new to VB - I am trying to run a DOS command from within a VB2005 asp.net web site using a command button? The DOS command will take the form of the command followed by several...
15
12512
by: simonoficina | last post by:
Hello all! I am a vb.net beginner in Spain. When I use VB6 ,the button object has a property called "default" that can set this button like press "ENTER" key. But in the VB.net I can't find this...
2
2741
by: Milan | last post by:
Hi, Please guide me how to set command line argument and how to retrive command line argument. Senario: vb.net application should be able to execute from command prompt by passing login and...
8
3539
by: cj | last post by:
In 2003 I sometimes changed the startup object of a project to Sub Main which was found in Module1.vb. I upgraded one such project to 2005 and I notice in the properties page for the project that...
1
1650
by: erickwan88 | last post by:
I am doing a final year project for my school and is going to provide for an organization, so I am asking for some help on here. Indeed, I have no idea on how to get the input from my pen driver...
0
7105
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,...
0
7132
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,...
0
7180
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...
0
7341
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...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
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...
0
4564
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
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 ...

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.