Page 1 of 1

[b]Mysql Select Statement with variables[/b]

Posted: Sat 13 Nov 2004 08:13
by avi8tor
I am trying to create a query where I select a particular row based on a selection made from a radiolistbox in an aspx page. I have captured the selection using Context.Items.Add("") and Server.Transfer. I guess I could also use Sessions to do the same.
On the next page I capture the values okay and then want to query the database for a particular row value (actually I will be making a multiple query, but only one with a called row).

Can I assign a variable to the Select statement and how is this done?

For instance: "SELECT tbl1. [variable] FROM tbl1....." :?

Re: [b]Mysql Select Statement with variables[/b]

Posted: Mon 15 Nov 2004 15:27
by Oleg
You cannot pass parameters as you specified in your example.
Generate CommandText yourself, for example:

Code: Select all

mySqlCommand.CommandText = string.Format("SELECT tbl1.{0} FROM tbl1", columnName);

Posted: Mon 15 Nov 2004 20:38
by avi8tor
I will form the Command Text myself but now I am wondering what the
{0} means in your example. Is this related to MySql or part of MySqlDirect.Net?

Posted: Tue 16 Nov 2004 12:45
by Oleg
This placeholder '{0}' is related with .NET Framework class System.String.
Please read details in .NET Framework Reference (String.Format method).