-2
得到錯誤時嘗試變量插入到數據庫,使用Visual Studio 2012,數據庫類型SDF有一個錯誤解析查詢時插入
代碼是:
static public void InsertMember(String _MemberId, String _Surname, String _Forename, String _Phonenumber, String _Email, String _Country, String _CityTown, String _CountyZipCode)
{
try
{
connection.Open();
SqlCeCommand commandInsert = new SqlCeCommand("INSERT INTO [Members] VALUES(@MemberID, @Surname, @Forename, @Phonenumber, @Email, @Country, @CityTown, @CountyZipCode,)", connection);
commandInsert.Parameters.AddWithValue("@MemberID", _MemberId);
commandInsert.Parameters.AddWithValue("@Surname", _Surname);
commandInsert.Parameters.AddWithValue("@Forename", _Forename);
commandInsert.Parameters.AddWithValue("@Phonenumber", _Phonenumber);
commandInsert.Parameters.AddWithValue("@Email", _Email);
commandInsert.Parameters.AddWithValue("@Country", _Country);
commandInsert.Parameters.AddWithValue("@CityTown", _CityTown);
commandInsert.Parameters.AddWithValue("@CountyZipCode", _CountyZipCode);
commandInsert.ExecuteNonQuery();
}
catch (SqlCeException exeptions)
{
MessageBox.Show(exeptions.ToString());
}
finally
{
connection.Close();
}
你會得到哪個錯誤?你能從命令文本中刪除最後一個「**,**」嗎? – thepirat000
最後沒有額外的逗號嗎? –