我正在使用连接到 Access 数据库 (2010) 的 Visual Studio 2010。
我创建了一个按钮来将文本框中的项目添加到数据库中,但出现错误“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();
}