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

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

Postby avi8tor » Sat 13 Nov 2004 08:13

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....." :?
avi8tor
 
Posts: 18
Joined: Sat 06 Nov 2004 12:45
Location: Gig Harbor, Washington USA

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

Postby Oleg » Mon 15 Nov 2004 15:27

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);
Oleg
Devart Team
 
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Postby avi8tor » Mon 15 Nov 2004 20:38

Thanks
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?
avi8tor
 
Posts: 18
Joined: Sat 06 Nov 2004 12:45
Location: Gig Harbor, Washington USA

Postby Oleg » Tue 16 Nov 2004 12:45

This placeholder '{0}' is related with .NET Framework class System.String.
Please read details in .NET Framework Reference (String.Format method).
Oleg
Devart Team
 
Posts: 264
Joined: Thu 28 Oct 2004 13:56


Return to dotConnect for MySQL