Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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

 

i've got upto the section where you enter the page load event to fill in the data grid using the following VB 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

Edited by PlausiblyDamp
Posted
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

  • *Experts*
Posted

Make sure the file is not readonly and that it's not open in Access itself. Otherwise, I can't think of why you'd get that error.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...