• 0

[C#, ASP.NET] Access Database, Syntax Error


Question

Hi

I'm making website with a registration form. I've also made an access database for all information to be stored into. I'm going through the process of linking the database to the registration form so that when the user hits submit it saves all the date into the access database. When I run the page and click submit I keep getting the same Syntax Error "Syntax error in INSERT INTO statement".

My code is below, any help if greatly appreciated!

p.s, I know access isn't the best database to use but for this site I need to use it

Cheers

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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 Register_new : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
	protected void Submit_Form_Click(object sender, EventArgs e)
	{

		OleDbConnection a = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=I:/Max - Delete2/Max - Delete/App_Data/Zeon_Hire.mdb");
		string dbcommand = "INSERT into tblRegister (Title1, First_Name, Last_Name, Username, Password, Confirm_Password, Date1, Address_1, Address_2, City, Postcode, Country, Telephone_Number, Mobile, Email, Confirm_email) " + " VALUES ('" + Title1.Text + "'  , '" + First_Name.Text + "' , '" + Last_Name.Text + "' , '" + Username.Text + "' , '" + Password.Text + "' , '" + Confirm_Password.Text + "' , #" + Date1.Text + "#  , '" + Address1.Text + "' , '" + Address2.Text + "' , '" + City.Text + "' , '" + Postcode.Text + "' , '" + Country1.Text + "' , '" + Telephone_Number.Text + "' , '" + Mobile_Number + "' , '" + Email.Text + "' , '" + Confirm_Email.Text + "')";

		OleDbDataAdapter b = new OleDbDataAdapter(dbcommand, a); DataSet dset = new DataSet();
		b.Fill(dset);

	}
}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.