View Single Post
  #1 (permalink)  
Old March 11th, 2007, 09:38 AM
csharpa csharpa is offline
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default converting and sending data problem

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?
Reply With Quote