B
buzz
I am using Compact Framework; C#.
I have a situation where I need to retrieve the autoincrement value from the
primary key of a table.
I use the following code:
DataRow dr = _dsCall.Tables[0].NewRow();
_dsCall.Tables[0].Rows.Add(dr);
_daCall.Update(_dsCall, "Calls");
SqlCeCommand cmd = new SqlCeCommand("SELECT @@IDENTITY",
Database.Connection);
caid = (int)cmd.ExecuteScalar();
The ExecuteScalar cast fails, because it is returning a decimal value, even
though the primary key is an INT!!??
To resolve this, and convert to a string and back:
caid = Int32.Parse(cmd.ExecuateScalar().ToString());
Any ideas as to why ExecuteScalar is returning a decimal??
Thanks.
I have a situation where I need to retrieve the autoincrement value from the
primary key of a table.
I use the following code:
DataRow dr = _dsCall.Tables[0].NewRow();
_dsCall.Tables[0].Rows.Add(dr);
_daCall.Update(_dsCall, "Calls");
SqlCeCommand cmd = new SqlCeCommand("SELECT @@IDENTITY",
Database.Connection);
caid = (int)cmd.ExecuteScalar();
The ExecuteScalar cast fails, because it is returning a decimal value, even
though the primary key is an INT!!??
To resolve this, and convert to a string and back:
caid = Int32.Parse(cmd.ExecuateScalar().ToString());
Any ideas as to why ExecuteScalar is returning a decimal??
Thanks.