I have a database connected successfully by "OLEDB" connection. I've used one table for the sign up form and it worked perfectly and then I used the other table with another form, but with the same code, with the differences that are needed, yet I keep getting this error:
Syntax error in INSERT INTO statement.
The error is for this part of the code:
{
string sqlpost2 = "insert into postqr(Professor,Title,Body)";
sqlpost2 += "value('" + postname + "','" + posttitle + "','" + postbody + "')";
DBFunction.ChangeTable(sqlpost2, "DBS.accdb");
}
This is all of the code used in that page:
protected void Button9_Click(object sender, EventArgs e)
{
string postname = this.Postuser.Text;
string postpass = this.Postpass.Text;
string posttitle = this.TOP.Text;
string postbody = this.BOP.Text;
string sqlstr2 = "select * from professors WHERE pname='" + postname + "' AND ppass='" + postpass + "'";
DataTable dt1 = DBFunction.SelectFromTable(sqlstr2, "DBS.accdb");
if (dt1.Rows.Count > 0)
{
string sqlpost2 = "insert into postqr(Professor,Title,Body)";
sqlpost2 += "values('" + postname + "','" + posttitle + "','" + postbody + "')";
DBFunction.ChangeTable(sqlpost2, "DBS.accdb");
}
else
this.Label1.Text = "Posting on this wall is only allowed for professors and it seems that you're not one";
DataList1.DataBind();
}
OleDbParameters.values(...)notvalue(...)it doesn't work for meyou should post that code so you can get the help you badly need. For this, check the spaces and spelling