You can pass the variable value, as a parameter, into a stored procedure call, or in a dynamically created query string.
Main Topics
Browse All TopicsIs it possible to compare a global C# variable in a MySQL query?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you have an SqlDataSource, then you can dynamically create the SelectCommand in the Page_Load event handler, or define a parameter.
http://msdn.microsoft.com/
Example:
I've researched more on parameters thanks to your help. I'm having trouble assigning the parameter the HttpContext.Current.User.I
Thanks
You aren't using named parameters, so I am not sure if that will find a match, and set a value. You can find out by testing in the SqlDataSource.Selecting event handler:
Example:
Bind Data From a SqlDataSource to a Label
http://www.mikesdotnetting
protected void SqlDataSource1_Selecting(o
{
e.Command.Parameters["Empl
}
You can see that it is possible to set the parameter value in that event handler, before the data is selected.
I tried but I am still unsure how to do it. When I try to implement it on an .aspx page I get this error: An error occurred during the compilation of the requested file, or one of its dependencies. The type or namespace name 'DataView' could not be found (are you missing a using directive or an assembly reference?). But I am unable to put "using System.Data;" at the top of the page.
The SqlDataSource.Select method executes the underlying SqlCommand, and the type that is returned depends on how the SqlDataSource is defined.
SqlDataSource.Select Method
http://msdn.microsoft.com/
"The Select method returns a DataView object if the DataSourceMode property is set to the DataSet value. The Select method returns a IDataReader object if the DataSourceMode property is set to the DataReader value. Close the IDataReader object when you have finished reading the data."
Business Accounts
Answer for Membership
by: angelIIIPosted on 2009-08-04 at 14:05:18ID: 25018150
short answer: yes.
long answer: you have (of course) to put the variable into the sql query itself.
mysql, per se, cannot know of a c# variable, global or not global