SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
SqlCommand command = new SqlCommand();
command.CommandText =
"INSERT INTO [Users]
VALUES ([email protected], [email protected]
, [email protected], ProfilePic=NULL, [email protected], [email protected]
, [email protected], [email protected], [email protected])";
command.Parameters.AddWithValue("@username", m_username);
command.Parameters.AddWithValue("@firstname", m_firstname);
command.Parameters.AddWithValue("@lastname", m_lastname);
command.Parameters.AddWithValue("@bio", m_bio);
command.Parameters.AddWithValue("@email", m_email);
command.Parameters.AddWithValue("@emailverified", (m_emailIsVerified ? "yes" : "no"));
command.Parameters.AddWithValue("@hash", m_hash);
command.Parameters.AddWithValue("@companyid", m_companyID);
command.CommandType = CommandType.Text;
command.Connection = sqlConnection;
sqlConnection.Open();
command.ExecuteNonQuery();
sqlConnection.Close();
通過上面的代碼,我得到「Syntax error near =」錯誤。我做錯了什麼?「不正確的語法附近'='」運行時錯誤c#asp.net
閱讀關於insert sql語句。你的語法錯了。只需按照它們在表中的順序列出參數,不要有'ColumnName ='部分。 –