Store Byte array in SQLite using Blob

后端 未结 2 1084
陌清茗
陌清茗 2021-01-01 05:12

For my application I\'m trying to store a byte array in my SQLite application, I\'m filling my SQLite database this way:

public bool InsertMessage()
    {
           


        
相关标签:
2条回答
  • 2021-01-01 05:34

    Use an overload of SQLiteParameter that takes the DBType parameter:

    var dataParameter = new SQLiteParameter("Data", DbType.Binary) { Value = data };
    pars.Add(dataParameter);
    
    0 讨论(0)
  • 2021-01-01 05:56

    You should use parameters in the statement:

    string SQL = "INSERT INTO ClockMessages (InsertDateTime, SendDateTime, Data) VALUES (@InsertDateTime, NULL, @Data)";
    

    Everything else seems correct.

    What you have now, calls the ToString() method on insertdatetime and data and concatenates the result to the sql statement. Actually you are not using any parameter in the statement.

    0 讨论(0)
提交回复
热议问题