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

Recommended Answers

All 3 Replies

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;
       }

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

HI

Thanks

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.