-4
我已经搜索了我的答案,只是发现某人的代码中存在拼写错误。为什么我没有'ExecuteScalar'的定义?
我还未发现此代码无定义为ExecuteScalar()
的原因。当我实际将行添加到SQL数据库时,实际上我可能需要捕获Customer_Id
,因为它是自动增量。
这里是我的代码有问题:
if (customer_IDTextBox == null)
{
sqlConnection.Open();
string SQL = "SELECT MAX(Customer_ID) FROM Customer";
int maxId = Convert.ToInt32(SQL.ExecuteScalar());
sqlConnection.Close();
}
看到这是一个字符串扩展方法会很有趣。 – 2014-10-17 04:18:58