F
Frank Rizzo
I posted it on the mySQL forum, but no one seems to be answering
questions there.
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. Am I doing something
patently wrong?
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");
}
questions there.
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. Am I doing something
patently wrong?
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");
}