1
public static string storeAvatar(string avatar, string gender, string species, int playerforeignkey)
{
try
{
OleDbConnection myConnection = GetConnection();
OleDbCommand dbCommand = new OleDbCommand();
dbCommand.CommandText = "INSERT INTO AVATARS ([AVATAR_ID],[AVATAR],[DOB],[STRENGTH],[GENDER],[HOARD],[SPECIES], [METAMORPHOSED], [COST],[PLAYERID_FK]) values (?,?,?,?,?,?,?,?,?,?)"; // command to get high score data
dbCommand.Parameters.AddWithValue("@id", "AVATARS_SEQ.NEXTVAL");
dbCommand.Parameters.AddWithValue("@avatar", avatar);
dbCommand.Parameters.AddWithValue("@date", "TO_CHAR(" + DateTime.Now.ToString("dd/mm/yyyy")+")");
dbCommand.Parameters.AddWithValue("@strength", 0);
dbCommand.Parameters.AddWithValue("@gender", gender);
dbCommand.Parameters.AddWithValue("@hoard", 0);
dbCommand.Parameters.AddWithValue("@species", species);
dbCommand.Parameters.AddWithValue("@meta", 0);
dbCommand.Parameters.AddWithValue("@cost", 0);
dbCommand.Parameters.AddWithValue("@playerfk", playerforeignkey);
dbCommand.Connection = myConnection;
myConnection.Open();
dbCommand.ExecuteNonQuery();
myConnection.Close();
}
catch (Exception ex)
{
}
return "ERROR";
}
異常錯誤說我需要錯過SELECT
關鍵字,但是我想INSERT
而不是SELECT
。爲什麼我在數據庫插入命令中遇到異常錯誤?
EXCEPTION =「一個或多個錯誤 命令的處理過程中出現\ r \諾拉-00928:缺少SELECT關鍵字」
你能分享精確的異常消息?查詢中的參數被稱爲'?,?,?,?,?,?,?,?',它是故意的嗎?您需要在那裏使用實際的命令名稱。 –