11.10.2007 at 01:43AM PST, ID: 20255081 |
Rank: Sage
Did you try SELECT @@IDENTITY
Example
public Client CreateClient( string name )
{
OleDbCommand command = null;
Client c = new Client();
c.Name = name;
try
{
command = Connection.CreateCommand()
command.CommandText = "insert into Clients (name) values(@name)";
command.Parameters.Add("@n
command.ExecuteNonQuery();
// Retrieve ID
command.CommandText = "SELECT @@IDENTITY";
c.ID = Int64.Parse(command.Execut
return c;
}
finally
{
command.Dispose();
}
Brak komentarzy:
Prześlij komentarz