{
List customers = new List();
con.Open();
using (SqlCommand cmd = new SqlCommand("Select Id, CompanyRefId from SalesMan where salesmanname=@salesmanname and code=@usercode", con))
{
cmd.Parameters.AddWithValue("@salesmanname", salesmanname);
cmd.Parameters.AddWithValue("@usercode", usercode);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
customer c1 = new customer();
c1.id = (int)reader["Id"];
c1.companyrefid = (Guid)reader["CompanyRefId"];
customers.Add(c1);
}
return customers;
}
}
}
this is the code i have used but i am getting only id value and not companyrefid while returning in list .how to get both ?.using break point i checked i am getting id value and companyrefrid.
Lakshmanan Sethu SankaranarayanPosted Jun 1, 2014, 4:21 AM
Anupam SinghPosted Jun 1, 2014, 3:22 AM
c1.companyrefid = (Guid)reader["CompanyRefId"];
to
c1.companyrefid = (string)reader["CompanyRefId"];
make the same changes in customer class.
because there might be some issue while converting it into GUID.
Hope this will help.