我试图将数据插入ms访问数据库,但我在insert into语句中不断出现语法错误。
代码:
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
public partial class Default2 : System.Web.UI.Page
{
OleDbConnection mycon;
protected void Page_Load(object sender, EventArgs e)
{
mycon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\sidd\Desktop\Database1.mdb");
}
protected void Button1_Click(object sender, EventArgs e)
{
string insertcmd = "insert into comp (pro_ps,pro_type,pro_nam,pro_det) values( '"+TextBox1.Text +"','"+TextBox1.Text +"','"+TextBox1.Text+"','"+TextBox1.Text+"')";
OleDbCommand cmd = new OleDbCommand(insertcmd, mycon);
mycon.Open();
cmd.ExecuteNonQuery();
TextBox2.Text = "DONE";
}
}