簡體   English   中英

帶參數方向的Finisar SQLite問題

[英]Finisar SQLite Problem with ParameterDirection

private int GetNextId()
{
    SQLiteConnector conn = new SQLiteConnector(false);
    conn.OpenConnection();
    cmd = new SQLiteCommand("SELECT @id_account = MAX(id_account) FROM account");
    SQLiteParameter param = new SQLiteParameter("@id_account", DbType.Int32);
    param.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(param);
    cmd = conn.ExecuteReadeOutput(cmd);
    conn.Close();
    return int.Parse(cmd.Parameters["id_account"].Value.ToString()) + 1;
}
...
public SQLiteCommand ExecuteReadeOutput(SQLiteCommand cmd)
{
    conn.Open();
    cmd.Connection = conn;
    reader = cmd.ExecuteReader();
    reader.Close();
    return cmd;
}

當我調用方法GetNextId()時,發生以下錯誤:

指定的參數超出有效值范圍。

在行:

param.Direction = ParameterDirection.Output;

任何想法?

謝謝。

不是您問題的直接答案,但是如果您只寫:

SELECT MAX(id_account) FROM account

然后可以通過普通的DataReader檢索唯一值。 在這種情況下,無需聲明任何參數。

露西安

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM