Hiya -i'm using the following code for a button_click event, and works fine, but i just thought the connection string should be referencing the web.config file, not sure how to do this any pointers?
and the web.config file:
Code:
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|DB1.mdb;User Id=admin;Password=;");
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "INSERT INTO Xref_Roles_Users (Role, Users) VALUES ('" + Request.Form["DropDownList1"] + "','"+Request.Form["ListBox1"]+"')";
cmd.Connection = cn;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
cmd.Dispose();
cn.Dispose();
}
and the web.config file:
Code:
<appSettings/>
<connectionStrings>
<add name="DBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DB1.mdb;Persist Security Info=True"
providerName="System.Data.OleDb" />
</connectionStrings>
<system.web>....