我已经读过,为了将图像保存到我的数据库中,我需要一个名为BLOB的数据类型。此外,在此链接Microsoft Access Data Types中,要在我的数据库中添加一列 BLOB 在 Microsoft Access 中工作,我需要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");
}
}
我想在表格项目中向我的数据库中添加一个列图片,例如,我可以在其中保存人们附加的图片。我也试过了,这三种情况都抛出异常:string sql = "ALTER TABLE item ADD picture OLE OBJECT
string 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.
如何为图片添加此列?谢谢!