NetConnector Query Parameter with @ does not function as per document
Posted by: ravi magod
Date: October 23, 2012 09:50PM

Hi

I was trying to write a Query and pass a parameter. It works fine if I embed the criteria in the CommandText, if I use Parameter with @ indentifier it does not work.

'***** SERVER MySQL 5.0.67 -community-nt via TCP/IP
'**** NetConnector for Mysql Version 5.0.8.1

The actual code is

Dim cmd As MySqlCommand = X.getCommand


With cmd
.Connection.Open()

'***** This does not work
.CommandText = "SELECT * FROM tycoonlist WHERE Type=@Type;"
.Parameters.AddWithValue("@Type", "Individual")
.Parameters("@Type").Direction = ParameterDirection.Input

Dim rdr As MySqlDataReader = .ExecuteReader
'**** Return empty

Do While rdr.Read
Console.WriteLine(rdr.Item("UID"))
Loop
rdr.Close()
'**** This Works
.CommandText = "SELECT * FROM tycoonlist WHERE Type='Individual';"

rdr = .ExecuteReader
Do While rdr.Read
Console.WriteLine(rdr.Item("UID"))
Loop


.Connection.Close()
End With

Any ideas why and to make it work as per documentation?

Regards

Ravi

Options: ReplyQuote


Subject
Written By
Posted
NetConnector Query Parameter with @ does not function as per document
October 23, 2012 09:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.