StaffanB 0 Newbie Poster

I have an Access database (Databas1.mdb) with one table (Tabell1) containing one column only (SomeData). The column is Text and has the primary key assigned to it.

Executing the code, i.e. clicking btnAdd gives a synrax error on the INSERT INTO-command when reaching the cmd.ExecuteNonQuery()-statement.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Configuration;

public partial class _Default : System.Web.UI.Page 

    protected void Page_Load(object sender, EventArgs e)

    protected void btnAdd_Click(object sender, EventArgs e)
        ConnectionStringSettings cs;
        cs = ConfigurationManager.ConnectionStrings["Databas1"];
        string connString = cs.ConnectionString;
       // connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Users\staffan\Documents\Visual Studio 2008\WebSites\SyntaxError\App_Data\Databas1.mdb""
       //providerName="System.Data.OleDb" />
        OleDbConnection dbConn = new OleDbConnection(connString);
        //OleDbCommand cmd = new OleDbCommand("INSERT INTO Tabell1 (SomeData) VALUE (?)", dbConn);
        //OleDbCommand cmd = new OleDbCommand("INSERT INTO [Tabell1] ([SomeData]) VALUE (?)", dbConn);
        cmd.Parameters.AddWithValue("SomeData", TextBox1.Text);
        cmd.ExecuteNonQuery();                  //This is where the error occurs

Can anyone explain why?

Inserting using a FormsView object works fine allthough the generated INSERT-statement looks exactly the same.

Is there a way to see the FormsView-object generated code?