Do parameterized commands work with MySQL ado.net provider?
Posted by: frank rizzo
Date: February 05, 2007 07:09PM

Hello, tearing my hair out. Do parameterized commands work with MySQL ado.net provider or not? I don't see any documentation on this. I've looked at the provider code and don't see any obvious places where parameter replacement takes place. Here is the piece of code in question.

I am using vs2005/c# with Ado.net driver for MySQL v5.0.3.0 and the latest MySQL 5.0 Community Server.


static void Main(string[] args)
{
const string FIELD_FILE_ID = "@FileID";

MySqlConnection conn = new MySqlConnection("data source=localhost;user id=root;password=root;initial catalog=testdb");
conn.Open();
MySqlCommand cmd = conn.CreateCommand();

cmd.CommandText = "SELECT files.strStoragePath FROM files WHERE (files.numFileID = @FileID)";
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("@FileID", MySqlDbType.Int32);
cmd.Parameters["@FileID"].Value = 117;

DataTable dataTable = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dataTable);
da.Dispose();

if (dataTable != null)
{
if (dataTable.Rows.Count > 0)
Console.WriteLine("Yeah Data");
else
Console.WriteLine("No Rows");
}
else
Console.WriteLine("Data Table does not exist");
}

Options: ReplyQuote


Subject
Written By
Posted
Do parameterized commands work with MySQL ado.net provider?
February 05, 2007 07:09PM


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.