我正在使用Visual Studio 2010連接到Access數據庫(2010)。INSERT INTO語句中的語法錯誤(Microsoft Access)
我創建了一個按鈕,從文本框項目添加到數據庫中,我得到的錯誤「語法錯誤INSERT INTO語句中」
protected void upload_Click(object sender, EventArgs e)
{
if (FileUpload3.HasFile)
{
try
{
string filename = Path.GetFileName(FileUpload3.FileName);
FileUpload3.SaveAs(Server.MapPath("images") + "/" + filename);
Picture.Text = "images/" + filename;
Label2.Text = "";
}
catch (Exception ex)
{
Label2.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}
protected void addnewitem_Click(object sender, EventArgs e)
{
AccessDataSource1.InsertCommand = "Insert into RAM (RAM Name, picture) values ('" + name.Text.ToString() + ",'" + Picture.Text.ToString() + "')";
AccessDataSource1.Insert();
}
封裝在方括號領域[RAM名稱。我認爲這個錯誤是由於列名中的空格造成的。 「插入RAM([RAM名稱],圖片)值」 –