hi,
i am using this code its working fine. i only have 2 confusion.
1. how can i create seperate class for all models like and call it where necessary.
2. secondly in some cases i need only to check whether my storeprocedure returns values or not if value return so print "has value" if not retrun so said "value"
please advice
public int Id { get; set; }
public string Name { get; set; }
public string Country { get; set; }
public class DataAccess
{
public int Id { get; set; }
public string Name { get; set; }
public string Country { get; set; }
public void Select(int CustomerId)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("getCustomerID", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@CustomerId", CustomerId);
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
Id = Convert.ToInt32(sdr["CustomerId"]);
Name = sdr["Name"].ToString();
Country = sdr["Country"].ToString();
}
con.Close();
}
}
}
}