I have this code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Access_Database
    public partial class Form1 : Form
        private OleDbConnection myconnection;

        public Form1()

        private void button1_Click(object sender, EventArgs e)

            string strconn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\dell\Desktop\Database\Student_Access.mdb;Persist Security Info=False";
            myconnection = new OleDbConnection(strconn);

            string query = "insert into tblStudent values('" + textBox1.Text + "','"+textBox2.Text+"','"+textBox3.Text+"');";
            OleDbCommand mycommand = new OleDbCommand(query, myconnection);


but the error is "could not find file"

what should i do?

I'm not that familiar with C# but try replacing




I'm not that familiar with C# but try replacing

The 'at' symbol in front of the initial double quote makes it a verbatim string literal; no escaping is necessary for the backslashes.

but the error is "could not find file"

I presume the exception is thrown in the call to myconnection.Open()--is that correct? Could you include the entire exception message?

Also, I have to ask... the file does exist, right? Can you copy that file path into Explorer and get Access to open the file?

If the file exists, then this might be a security/permissions-related issue.

This article has been dead for over six months. Start a new discussion instead.