Click here to Skip to main content
12,444,360 members (52,020 online)
Rate this:
 
Please Sign up or sign in to vote.
hi all

i got the above error when executing below code

but empname is also showed while inserting break point in .cs file


cmd = new SqlCommand("pdetails", con);
        cmd.CommandType = CommandType.StoredProcedure;
 
        p1 = new SqlParameter("@empid", SqlDbType.Int,50);
        p1.Value = Convert.ToInt32(cmbexistingemp.SelectedValue);
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empname", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empsex", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empdob", SqlDbType.Date,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empmobileno", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empaddress", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empnationality", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empdesig", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empskill", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
        p1 = new SqlParameter("@empmailid", SqlDbType.VarChar,50);
        p1.Direction = ParameterDirection.Output;
        cmd.Parameters.Add(p1);
 
        con.Open();
 
        cmd.ExecuteNonQuery();
        con.Close();
        txtename0.Text = cmd.Parameters["@empname"].Value.ToString();
        //txtsex0.Text = cmd.Parameters["empsex"].Value.ToString();
       // txtdob0.Text =cmd.Parameters["empdob"].Value.ToString();
        txtaddress0.Text = cmd.Parameters["empaddress"].Value.ToString();
        txtmobileno0.Text = cmd.Parameters["empmobileno"].Value.ToString();
        txtmailid0.Text = cmd.Parameters["empmailid"].Value.ToString();
        txtnationality0.Text = cmd.Parameters["empnationality"].Value.ToString();
        txtdesignation0.Text = cmd.Parameters["empdesig"].Value.ToString();
        txtempskill0.Text = cmd.Parameters["empskill"].Value.ToString();
Posted 1-Jan-13 6:41am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Shouldn't you be doing this:

txtaddress0.Text = cmd.Parameters["@empaddress"].Value.ToString();
  Permalink  
Comments
ProgramFOX 1-Jan-13 12:53pm
   
Good answer, +5!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100