Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
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 at 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
0 Maciej Los 655
1 OriginalGriff 453
2 CPallini 239
3 CHill60 180
4 Peter Leow 175
0 OriginalGriff 6,092
1 Sergey Alexandrovich Kryukov 4,898
2 Maciej Los 3,159
3 Peter Leow 3,129
4 DamithSL 2,490


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
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