Hi

Once I complie below coding part,it give me error meassage.The Error Meassage is Error

. The name 'CurrentOutLet' does not exist in the current context

BelowI write my coding

.
public SqlDataReader Current_outletReport(string code, string startdate, string enddate)
       {

           try
           {
               SqlDataReader CurrentOutLet;
               SqlConnection con;

               string str = "SELECT SUM(Active_Outlet) AS ............";
               con = DbCon.create_sqlconnection();
               con.Open();
               SqlCommand cmd = new SqlCommand(str, con);
               CurrentOutLet = cmd.ExecuteReader();
               con.Close();

           }
           catch (Exception e)
           {

           }
           return CurrentOutLet;
       }

Thanks
Tank50

You need to declare "CurrentOutLet" before the try...catch block. Copy and paste the code below; Good luck!

public SqlDataReader Current_outletReport(string code, string startdate, string enddate)
       {
         SqlDataReader CurrentOutLet;

           try
           {
              SqlConnection con;

               string str = "SELECT SUM(Active_Outlet) AS ............";
               con = DbCon.create_sqlconnection();
               con.Open();
               SqlCommand cmd = new SqlCommand(str, con);
               CurrentOutLet = cmd.ExecuteReader();
               con.Close();

           }
           catch (Exception e)
           {

           }
           return CurrentOutLet;
       }
.
public SqlDataReader Current_outletReport(string code, string startdate, string enddate)
       {

           try
           {
               SqlDataReader CurrentOutLet;
               SqlConnection con;

               string str = "SELECT SUM(Active_Outlet) AS ............";
               con = DbCon.create_sqlconnection();
               con.Open();
               SqlCommand cmd = new SqlCommand(str, con);
               CurrentOutLet = cmd.ExecuteReader();
               con.Close();

           }
           catch (Exception e)
           {

           }
           return CurrentOutLet;
       }

Edited 3 Years Ago by Dani: Formatting fixed

You need to declare "CurrentOutLet" before the try...catch block. Good luck!

This question has already been answered. Start a new discussion instead.