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 7: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 OriginalGriff 270
1 Sergey Alexandrovich Kryukov 185
2 BillWoodruff 173
3 CPallini 155
4 Kamal Rocks 144
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.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