sql = "insert into table1 (username,age) values ('zhang',20);select @@identity as 'id'"; int i = Convert.ToInt32(Command.ExecuteScalar());