Khodam A

Khodam A

  • NA
  • 12
  • 0

converting and sending data problem

Mar 11 2007 10:16 AM

Hi,

I want to send the FK from parent table to child table by getting the object with executescalar and converting the value of it to string and then to integer finally pass it to child table. The problem is that the converted data will lose the information. I mean it will become NULL.

This is how did I do:

 

insertCommand.CommandText = "SELECT @@IDENTITY AS P_ID ";

           

SqlParameter pIDParameter = new SqlParameter("@P_ID", SqlDbType.Int);

pIDParameter.Direction = ParameterDirection.ReturnValue;

object o = insertCommand.ExecuteScalar();

string s = o.ToString();

int P_ID = Int32.Parse(s);

 

what is the better way to the convertion or better way to pass it to child table?