Mahendra Kumar

Mahendra Kumar

  • NA
  • 164
  • 5.4k

How to make connection String from MS Access database

Jan 4 2018 12:00 AM
How to make connection String from MS Access database in asp.net
 I am using following code 
 
protected void btnAccessDataBase_Click(object sender, EventArgs e)
{

OleDbConnection conn = new OleDbConnection();

conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Mahendra\Student.mdb; User id=admin;Password=password;";

string sqlqry = "Insert into tblStudent(FirstName,LastName)Values('" + txtFirstName.Text + "','" + txtLastName.Text + "')";
OleDbCommand cmd = new OleDbCommand(sqlqry, conn);
conn.Open();
int a = cmd.ExecuteNonQuery();
conn.Close();
if (a > 0)
{

}
 
What is going on here?

Thanks,
--Mahendra

Answers (5)