hello everybody nice to be in the community
i have question regarding micrsoft visual 2008 i'm using asp.net with c# and i want to connect asp.net with access db 2007
i used select command and it worked it shows the data from access 2007 but when i tried to use insert command from asp.net it didnt work
and here is the code
-------

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

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string DBpath = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\amerh\Documents\Visual Studio 2008\WebSites\amer\ER.accdb;Persist Security Info=True";
        OleDbConnection con = new OleDbConnection(DBpath);
        string sql = "insert into Main(Module,Sub Module,Screen Number,Date,Employee,IT Side,Status)values(" + TextBox1.Text + ",'" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "', '" + TextBox5.Text + "', '" + DropDownList1.SelectedValue + "','" + DropDownList2.SelectedValue + "')";
        OleDbCommand cmd = new OleDbCommand(sql, con);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
       
       
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string DBpath = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\amerh\Documents\Visual Studio 2008\WebSites\amer\ER.accdb;Persist Security Info=True";
        OleDbConnection con = new OleDbConnection(DBpath);
        string sql = "insert into login(username,password)values(" + TextBox6.Text + ",'" + TextBox7.Text + "')";
        OleDbCommand cmd = new OleDbCommand(sql, con);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    }
}

thank you

Hi

Whats the error message??

the message is error in insert syntax

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.