public string QueryExe(Customer cs) { string sqlstatement = "select Name from Customer where Pic=@pic"; SqlCommand cmd=new SqlCommand(sqlstatement,con); cmd.Parameters.AddWithValue("@pic", cs.Pic); string dataret=string.Empty; try { SqlDataReader mydatareader = null; con.Open(); mydatareader= cmd.ExecuteReader(); while (mydatareader.Read()) { dataret=mydatareader["Name"].ToString(); } } catch (SqlException se) { MessageBox.Show(se.Message); } catch(NullReferenceException nre) { MessageBox.Show(nre.Message); } return dataret; }
private void button1_Click(object sender, EventArgs e) { int pic = Convert.ToInt32(PICTextBox.Text); Customer cust = new Customer(); cust.Pic = pic; CustDetTableAccess cdta=new CustDetTableAccess(); cdta.Sqlcon(); string retcustname=cdta.QueryExe(cust); EnterPincode ep=new EnterPincode(); ep.Customername = retcustname; ep.Show(); this.Dispose(); }