Manipulating an Access DB in Visual Studio.net 2003 in C#

Heple

Member
Joined
Feb 20, 2006
Messages
7
I want to link to a Microsoft Access database in visual studio. i am coding in C# and have found how to do using the site below

http://www.geekpedia.com/prog_ttrls.php?id=158

ive got upto the section where you enter the page load event to fill in the data grid using the following VB Code
Code:
        private void Page_Load(object sender, System.EventArgs e)
        {
            Dim myReader As System.Data.OleDB.OleDBDataReader;
            OleDBConnection1.Open();
            myReader= OleDbCommand1.ExecuteReader();
            ISPDataGrid1.DataSource = myReader;
            ISPDataGrid1.DataBind();
        }
Can someone help me convert this to C# code as i am struggeling to perform this in C#.

Thanks

Craig
 
Last edited by a moderator:
C#:
private void Page_Load(object sender, System.EventArgs e)
{
System.Data.OleDB.OleDBDataReader myReader;
OleDBConnection1.Open();
myReader= OleDbCommand1.ExecuteReader();
ISPDataGrid1.DataSource = myReader;
ISPDataGrid1.DataBind();
}
 
PlausiblyDamp said:
C#:
private void Page_Load(object sender, System.EventArgs e)
{
System.Data.OleDB.OleDBDataReader myReader;
OleDBConnection1.Open();
myReader= OleDbCommand1.ExecuteReader();
ISPDataGrid1.DataSource = myReader;
ISPDataGrid1.DataBind();
}

Cheers

That worked fine and all compiled ok.

But

When i run it i get this error

The Microsoft Jet database engine cannot open the file D:\Inetpub\wwwroot\bandwidthmonitor\ISPDatabase.mdb. It is already opened exclusively by another user, or you need permission to view its data.

Its not been opened by another program. I am the administrator i thought i would have permission.

Do you know why it has thrown up this error.

Craig
 
Make sure the file is not readonly and that its not open in Access itself. Otherwise, I cant think of why youd get that error.

-ner
 
Back
Top