[HttpPost]
public void InsertOrUpdateDirector(Director director)
{
int idReturned = 0;
string query = null;
myConnection.Open();
if (director.Operation == 'I')
{
query = "INSERT...";
}
else if (director.Operation == 'U')
{
query = "UPDATE ...";
}
var cmd = new SqlCommand(query, myConnection);
cmd.ExecuteNonQuery();
myConnection.Close();
idReturned = "???";
return idReturned;
}
我只是想在插入语句之后返回新创建的 ID。我该怎么做呢?