Menu

#1 SqlServerIdentitySelector fails on SQL Server 2005

open
nobody
None
5
2007-11-21
2007-11-21
Anonymous
No

When I try using a SqlServerIdentitySelector, it gives an error "InvalidCastException". To correct this, I had to modify the retrieveIdentity method as follows.

public int retrieveIdentity(IDbConnection connection)
{
int id = -1;
using (IDbCommand cmd = connection.CreateCommand())
{
cmd.CommandText = IdentitySelectStatement();
String str = cmd.ExecuteScalar().ToString();
if (str != null)
{
Int32.TryParse(str, out id);
}
}
return id;
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.