Hi
I have create a class with 2 methods. method 1 is used to create and open the mysql connection.
Method 2 is the query method where a query is passed in from my aspx page.
But when i send the query through i get the error as shown in the subject line.
here is the code for the query
MySqlCommand mysqlcmd = new MySqlCommand(strQuery, conSQL);
MySqlDataReader mysqlReader = mysqlcmd.ExecuteReader();
code from the aspx page is
protected void but_connclass(object sender, EventArgs e)
{
conClass conCL = new conClass(); //instance of the class
if (conCL.DBConnect() == true)
{
string strQry = "Select * FROM tblclients";
if (conCL.DBquery(strQry) == true) --> errors occurs here!!!!!
{
lblconclass.Text = "hanji";
}
}
i think the problem is MySqlCommand mysqlcmd = new MySqlCommand(strQuery, conSQL); where the conSQL is defined in a different method
method dbconnect
MySqlConnection conSQL = new MySqlConnection(strConnection);
conSQL.ConnectionString = strConnection;
so how can i make that variable in scope with the second method as there are 2 seperate calls to the each method.
regards
Tj