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 CHill60 380
1 Sergey Alexandrovich Kryukov 245
2 Richard MacCutchan 152
3 CPallini 150
4 Peter Leow 150
0 Sergey Alexandrovich Kryukov 9,193
1 OriginalGriff 6,786
2 Peter Leow 4,332
3 Zoltán Zörgő 3,809
4 Richard MacCutchan 2,672


Advertise | Privacy | Mobile
Web01 | 2.8.150128.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2015
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