error:unassigned local variable 'value'?
-
hi all , i wrote one webmethod in webservice , from that webmethod i am returning string but i am getting unassigned local variable value , how to solve this problem? [WebMethod] public string GetCountryList() { string connectionString = ConfigurationManager.ConnectionStrings["iphoneConnection"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); SqlCommand comm = new SqlCommand(); comm.CommandType = CommandType.StoredProcedure; comm.CommandText = "sp_name"; comm.Connection = connection; connection.Open(); SqlDataReader objdatareader; objdatareader=comm.ExecuteReader(); string Value; while (objdatareader.Read()) { Value = objdatareader.ToString(); } objdatareader.Close(); connection.Close(); return Value; } Thanks& Regards RamaDevi.
samrama
-
hi all , i wrote one webmethod in webservice , from that webmethod i am returning string but i am getting unassigned local variable value , how to solve this problem? [WebMethod] public string GetCountryList() { string connectionString = ConfigurationManager.ConnectionStrings["iphoneConnection"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); SqlCommand comm = new SqlCommand(); comm.CommandType = CommandType.StoredProcedure; comm.CommandText = "sp_name"; comm.Connection = connection; connection.Open(); SqlDataReader objdatareader; objdatareader=comm.ExecuteReader(); string Value; while (objdatareader.Read()) { Value = objdatareader.ToString(); } objdatareader.Close(); connection.Close(); return Value; } Thanks& Regards RamaDevi.
samrama