Click here to Skip to main content
15,904,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
(when i am running this code it is giving an error near "if(rdr.Read())" that failed to convert varchar to numeric)
private void Balance_Enquiry_Load(object sender, EventArgs e)
{
//label3.Visible = false;
SqlConnection con = new SqlConnection(@"data source=ABHINAV-PC\ABHI;integrated security=true;initial catalog=ATM;");
con.Open();
SqlCommand cmd = new SqlCommand("select * from transactions where account_no='" + label2.Text + "'", con);
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.Read())
{
label2.Text = rdr["total"].ToString();
}
rdr.Close();
rdr.Dispose();
con.Close();
}
Posted

1 solution

Hi
Try this hope this will work

SqlCommand cmd = new SqlCommand("select * from transactions where account_no='" +Convert.ToInt16(label2.Text) + "'", con);
 
Share this answer
 
Comments
Abhinav Chaudhary 12-Mar-14 8:45am    
Thank you sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900