Hello all,
I have a need to use "select @@identity" to get the autoid on the row
that I just inserted. The insert store procedure executed correctly as
if I took out the transaction, i can see the row being inserted. I just
can't get back the id that's all. I use MS ACCESS btw (using a third
party oledb add on, not sure if that's why it's causing problem)
Database InvestmentsDb = DatabaseFactory.CreateDatabase( "Investments"
);
using (IDbConnection connection = InvestmentsDb.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try{
DBCommandWrapper Proc_Login_Insert =
InvestmentsDb.GetStoredProcCommandWrapper(this.pro c_Logins_Insert);
Proc_Login_Insert.AddInParameter("@UserName",
DbType.String,
this.userName); Proc_Login_Insert.AddInParameter("@Password",
DbType.String,
this.password); Proc_Login_Insert.AddInParameter("@Email",
DbType.String, this.email);
Proc_Login_Insert.AddInParameter("@RoleType", DbType.String,
"investor");
InvestmentsDb.ExecuteNonQuery(Proc_Login_Insert, transaction);
String id = "";
id =
Convert.ToString(InvestmentsDb.ExecuteScalar(Comma ndType.Text,"Select
@@Identity"));
log.Debug("Id is:"+id);