昨天在.NET区发了一个关于SQL的帖子无人问津
yibey 2010-08-24 10:33:50
sql = @"insert into contact(contactName,nickName,address,city,state,crossStreets,postalCode,otRestaurantId,otNeighborhood,otCuisine,otPrice,colorCode,version,sharedContactId,enteredBy,entryDate)
values(@contactName,@nickName,@address,@city,@state,@crossStreets,@postalCode,@otRestaurantId,@otNeighborhood,@otCuisine,@otPrice,@colorCode,@version,@sharedContactId,@enteredBy,getDate());
select @@nestlevel,scope_identity()";
cmd = new SqlCommand(sql, siteconnc);
cmd.Transaction = sqlTran;
cmd.Parameters.AddWithValue("@contactName", row["primaryName"]);
cmd.Parameters.AddWithValue("@nickName", row["phoneNumber"]);
cmd.Parameters.AddWithValue("@address", row["address"]);
cmd.Parameters.AddWithValue("@city", row["city"]);
cmd.Parameters.AddWithValue("@state", row["state"]);
cmd.Parameters.AddWithValue("@crossStreets", row["crossStreet"]);
cmd.Parameters.AddWithValue("@postalCode", row["postalCode"]);
cmd.Parameters.AddWithValue("@otRestaurantId", row["openTableId"]);
cmd.Parameters.AddWithValue("@otNeighborhood", row["neighborhood"]);
cmd.Parameters.AddWithValue("@otCuisine", row["cuisine"]);
cmd.Parameters.AddWithValue("@otPrice", row["otprice"]);
cmd.Parameters.AddWithValue("@colorCode", "normal");
cmd.Parameters.AddWithValue("@version", 1);
cmd.Parameters.AddWithValue("@sharedContactId", row["contactId"]);
cmd.Parameters.AddWithValue("@enteredBy", "Gold Key Solutions");
string contactId = cmd.ExecuteScalar().ToString();
某人在.NET里使用这段代码,发现contactId竟然是等于2.有人知道这是为什么么求教