如何在数据库中添加 BLOB 列?

How to add BLOB column in database?

我读过 为了将图像保存到我的数据库,我需要一个名为 BLOB 的数据类型。此外,在这个 link Microsoft Access Data Types 中,为了在我的 Microsoft Access 数据库中添加一个列 BLOB,我需要 Ole Object.所以我做了一些这样的尝试:

public partial class alterOneSec : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        OleDbConnection con = DAL.GetConnection();
        con.Open();
        if(con.State == ConnectionState.Open)
        {
            string sql = "ALTER TABLE item ADD picture OLE";
            OleDbCommand cmd = DAL.GetCommand(con, sql);
            int num = cmd.ExecuteNonQuery();
            if(num == 0)
            {
                Response.Redirect("homepage.aspx?err=error");
            }
        }
        con.Close();
        Response.Redirect("homepage.aspx?err=case3");
    }
}

我想在我的数据库 table item 中添加一列 picture ,我可以在其中保存图片附加例如。我也试过 string sql = "ALTER TABLE item ADD picture OLE OBJECTstring sql = "ALTER TABLE item ADD picture BLOB" 这三种情况都抛出异常:

An exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll but was not handled in user code. Additional information: Syntax error in field definition.

如何为图片添加此栏? 谢谢!

尝试使用

ALTER TABLE item ADD picture LONGBINARY