Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Below mentioned code is working fine if i display data in one textbox but if if i add multiple texboxes it gives error==== "invalid operation exception was unhandled by user code"

Pls Pls Somebody help me....

thanks
Kshitija

C#
SqlCommand cmd = default(SqlCommand);
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString);
        con.Open();
        cmd = new SqlCommand("Select * from Call_Reg where Complaint_no='" + ddlupCompl.SelectedItem.ToString() + "'", con);
        SqlDataReader reader = cmd.ExecuteReader();
        while (reader.Read())

            txtFname.Text = Convert.ToString(reader["Cust_FName"]);
            txtLname.Text = Convert.ToString(reader["Cust_LName"]);
            txtPh.Text = Convert.ToString(reader["ph_no"]);
            txtMob.Text = Convert.ToString(reader["mob_no"]);
        con.Close();
Posted
Updated 3-Jan-13 0:06am
v2
Comments
[no name] 3-Jan-13 6:24am    
please write the code which is generating the error

1 solution

C#
while (reader.Read())
{
            txtFname.Text = Convert.ToString(reader["Cust_FName"]);
            txtLname.Text = Convert.ToString(reader["Cust_LName"]);
            txtPh.Text = Convert.ToString(reader["ph_no"]);
            txtMob.Text = Convert.ToString(reader["mob_no"]);
}


you missed the parenthesis
 
Share this answer
 
Comments
Member 9693583 3-Jan-13 6:29am    
Thanks HashamAhmad, Its working fine.. :)
[no name] 3-Jan-13 6:32am    
welcome

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