Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - command object vb2005 ado

Reply
 
Old 05-01-2008   #1 (permalink)
Rob


 
 

command object vb2005 ado

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



My System SpecsSystem Spec
Old 05-04-2008   #2 (permalink)
Cor Ligthert[MVP]


 
 

Re: command object vb2005 ado

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

My System SpecsSystem Spec
Old 05-04-2008   #3 (permalink)
Rob


 
 

Re: command object vb2005 ado

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]" <notmyfirstname@xxxxxx> schreef in bericht
news:E6C2060A-F7E0-4893-ACF3-986FC0651A7C@xxxxxx
Quote:

> 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

My System SpecsSystem Spec
Old 05-04-2008   #4 (permalink)
Cor Ligthert[MVP]


 
 

Re: command object vb2005 ado

Hi Rob,

Did you look at the code I made?

:-)

Cor

"Rob" <ROb@xxxxxx> schreef in bericht
news:uQRneycrIHA.5068@xxxxxx
Quote:

> 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]" <notmyfirstname@xxxxxx> schreef in bericht
> news:E6C2060A-F7E0-4893-ACF3-986FC0651A7C@xxxxxx
Quote:

>> 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
>
>
My System SpecsSystem Spec
Old 05-04-2008   #5 (permalink)
Rob


 
 

Re: command object vb2005 ado

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]" <notmyfirstname@xxxxxx> schreef in bericht
news:5E8F3612-5C8E-4CFD-85FF-C01FC0065399@xxxxxx
Quote:

> Hi Rob,
>
> Did you look at the code I made?
>
> :-)
>
> Cor
>
> "Rob" <ROb@xxxxxx> schreef in bericht
> news:uQRneycrIHA.5068@xxxxxx
Quote:

>> 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]" <notmyfirstname@xxxxxx> schreef in bericht
>> news:E6C2060A-F7E0-4893-ACF3-986FC0651A7C@xxxxxx
Quote:

>>> 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
>>
>>
>

My System SpecsSystem Spec
Old 05-05-2008   #6 (permalink)
Cor Ligthert[MVP]


 
 

Re: command object vb2005 ado

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" <ROb@xxxxxx> schreef in bericht
news:ucTg%23QjrIHA.4544@xxxxxx
Quote:

> 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]" <notmyfirstname@xxxxxx> schreef in bericht
> news:5E8F3612-5C8E-4CFD-85FF-C01FC0065399@xxxxxx
Quote:

>> Hi Rob,
>>
>> Did you look at the code I made?
>>
>> :-)
>>
>> Cor
>>
>> "Rob" <ROb@xxxxxx> schreef in bericht
>> news:uQRneycrIHA.5068@xxxxxx
Quote:

>>> 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]" <notmyfirstname@xxxxxx> schreef in bericht
>>> news:E6C2060A-F7E0-4893-ACF3-986FC0651A7C@xxxxxx
>>>> 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
>>>
>>>
>>
>
>
My System SpecsSystem Spec
Old 05-05-2008   #7 (permalink)
Rob


 
 

Re: command object vb2005 ado

Hi Cor,

Finaly , it works great
Many Thanks for yor help, Rob
"Cor Ligthert[MVP]" <notmyfirstname@xxxxxx> schreef in bericht
news:B248C6FF-2486-45D3-B61D-601D98843D6F@xxxxxx
Quote:

> 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" <ROb@xxxxxx> schreef in bericht
> news:ucTg%23QjrIHA.4544@xxxxxx
Quote:

>> 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]" <notmyfirstname@xxxxxx> schreef in bericht
>> news:5E8F3612-5C8E-4CFD-85FF-C01FC0065399@xxxxxx
Quote:

>>> Hi Rob,
>>>
>>> Did you look at the code I made?
>>>
>>> :-)
>>>
>>> Cor
>>>
>>> "Rob" <ROb@xxxxxx> schreef in bericht
>>> news:uQRneycrIHA.5068@xxxxxx
>>>> 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]" <notmyfirstname@xxxxxx> schreef in bericht
>>>> news:E6C2060A-F7E0-4893-ACF3-986FC0651A7C@xxxxxx
>>>>> 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
>>>>
>>>>
>>>
>>
>>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
stringfunctie Vb2005 .NET General
crystal reports Vb2005 .NET General
How to get the first object(s) from a slow command quickly? PowerShell
Invoking an object reference to a command? PowerShell
Adding canonical aliases for Compare-Object, Measure-Object, New-Object PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46