VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Parameters.count equals 0 Posted by tradm on 26 Nov 2008 at 3:15 AM
I am using VB.NET 2005 to access a MySQL 5 database.
I expected the following code snippet to give me a parameter count of 3 but it gives me 0.
Note:

- The connection to DB is established (tested)

Any ideas?
Please help!

'Create a connection to DB
Dim cn as New ADODB.Connection
cn.Mode = ADODB.ConnectModeEnum.adModeReadWrite
cn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
cn.Open("MyDSN_Name_ODBC")

'Run Parameter Query
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "INSERT INTO `tblgroups` ( " & _
           " `groupID` , `GroupName` , `Description` " & _
          " ) VALUES ( " & _
          "  ? , ? , ? " & _
          ")"
'Debug
Msgbox(cmd.Parameters.count) ' It gives me 0, WHY????
...


Report
Re: Parameters.count equals 0 Posted by seancampbell on 28 Nov 2008 at 7:20 PM
I have never used this style of code... Is it possible that it says that the count is 0 because you didn't add any parameters? You added Command text, but I think that is different from the Parameters object.

I will have to double check when I am home from vacation, I do not have my computer here, posting from my family's computer.

Hope you enjoyed your turkey day...
Sean C
Report
Re: Parameters.count equals 0 Posted by tradm on 29 Nov 2008 at 2:10 AM
: I have never used this style of code... Is it possible that it says
: that the count is 0 because you didn't add any parameters? You added
: Command text, but I think that is different from the Parameters
: object.
:
: I will have to double check when I am home from vacation, I do not
: have my computer here, posting from my family's computer.
:
: Hope you enjoyed your turkey day...
: Sean C

Sean,

I have explicitly added ther parameters and the code is now working ;)

With Ms SQL 2000, the parameters are automatically "created" (for some reasons the command object is intelligent enough to define the params based on the count of '?' and the data types from the table being referenced in the query)

Thanks
Mike.
Report
Re: Parameters.count equals 0 Posted by seancampbell on 1 Dec 2008 at 8:10 AM
Glad you got things working,
Happy Coding,
firesickle.com



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.