0
我有以下代碼,並運行此錯誤,我得到一個SqlException錯誤,說關鍵字'用戶'附近的語法無效。有任何想法嗎?猜測這很簡單,但我無法發現它。ASP.NET SqlConnection - 異常 - 錯誤的語法
string insertStmt =
"INSERT INTO User (UserName) VALUES(@UserName)";
using (SqlConnection _con = new SqlConnection(myConnectionString))
using (SqlCommand _cmd = new SqlCommand(insertStmt, _con))
{
_cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = UserName;
try
{
_con.Open();
_cmd.ExecuteNonQuery();
_con.Close();
}
catch (Exception x)
{
// output exception
}
}
謝謝。