When i run this as my first commend i get an exception an error near "last_insert_rowid"
. This is referring to the last last_insert_rowid();. If i set the curser to the line command.CommandText = and run it again it is fine.
What gives? The last_insert_rowid seems to be working properly why doesnt the last_insert_rowid after the 2nd insert work.
I tried moving last_insert_rowid() to after the execute and i still get an error. What gives?
using (var trans = connection.BeginTransaction())
{
command.CommandText =
"INSERT INTO link_list(link, status, hash_type, hash_id) " +
"VALUES(@link, @status, @hash_type, @hash_id);" +
"INSERT INTO active_dl(linkId, orderNo) " +
"VALUES(last_insert_rowid(), (SELECT COUNT(*) FROM active_dl)); last_insert_rowid();";
command.Parameters.Add("@link", System.Data.DbType.String).Value = link;
command.Parameters.Add("@status", System.Data.DbType.Int32).Value = SiteBase.Status.none;
command.Parameters.Add("@hash_type", System.Data.DbType.Int32).Value = 0;
command.Parameters.Add("@hash_id", System.Data.DbType.Int32).Value = 0;
int rowid = command.ExecuteNonQuery();
trans.Commit();
}