public List <customer> getSpecificCustomer(int custId) { SqlConnection conn = new SqlConnection(ConnectionString); conn.Open(); //string procedure_name = "getSpecificCustomer"; SqlCommand command = new SqlCommand("select * from Customer where customerId = " + custId, conn); SqlDataAdapter reader = new SqlDataAdapter(command); DataSet ds = new DataSet(); customer cobj = new WcfService.customer(); reader.Fill(ds); conn.Close(); List <customer> clist = new List <customer>(); int noofrows = ds.Tables[0].Rows.Count; int i = 0; while (noofrows != 0) { customer obj = new customer(); noofrows--; obj.CustomerID = int.Parse(ds.Tables[0].Rows[i]["CustomerID"].ToString()); obj.CustomerName = ds.Tables[0].Rows[i]["CustomerName"].ToString(); obj.Gender = ds.Tables[0].Rows[i]["Gender"].ToString().ElementAt(0); obj.Dob = ds.Tables[0].Rows[i]["Dob"].ToString(); obj.Address = (ds.Tables[0].Rows[i]["Address"].ToString()); obj.State = ds.Tables[0].Rows[i]["State"].ToString(); obj.Pincode = ds.Tables[0].Rows[i]["Pincode"].ToString(); obj.PhoneNo = ds.Tables[0].Rows[i]["PhoneNo"].ToString(); obj.Email = ds.Tables[0].Rows[i]["Email"].ToString(); obj.CreatedDate = ds.Tables[0].Rows[i]["CreatedDate"].ToString(); obj.EditedDate = ds.Tables[0].Rows[i]["EditedDate"].ToString(); obj.UserID = ds.Tables[0].Rows[i]["UserID"].ToString(); clist.Add(obj); i++; } return(clist); }
public DataSet getSpecificCustomer(int custId) { SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-R5QLBIQ\SQLEXPRESS;Initial Catalog=Bank;Integrated Security=True"); conn.Open(); //string procedure_name = "getSpecificCustomer"; SqlCommand command = new SqlCommand("select * from Customer where customerId = " + custId, conn); //SqlParameter id = new SqlParameter("@custId", custId); //command.Parameters.Add(id); //command.CommandType = System.Data.CommandType.StoredProcedure; SqlDataAdapter reader = new SqlDataAdapter(command); DataSet ds = new DataSet(); customer cobj = new WcfService.customer(); reader.Fill(ds); //gv.DataSource = ds; //gv.DataBind(); //var data=gv.Rows[0]; //var data1=data.Cells[0]; conn.Close(); return(ds); }