OleDB Connection Command and Reader, complication on Making it work!

Hi trying to Open a connection, Execute a select command and populate a datagrid with information from an access database.  The code compiles but I do not get any output.  All I have is one datagrid to be populated.  Please look at my code and let me know what I need to change or what I am doing wrong?  Thanks every1!

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data.OleDB" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="localhost.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>WebForm1</title>
            <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
            <meta content="JavaScript" name="vs_defaultClientScript">
            <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            <script language="vb" runat="server">
            Sub Page_Load(Src As Object, E As EventArgs)
                  Dim LinksConnection As OleDBConnection
                  Dim LinksCommand As OleDbCommand
                  
                  
                  LinksConnection = New OleDbConnection  ("Provider=Microsoft.Jet.OleDB.4.0;server=localhost;uid=Admin;pwd=;database=C:\Inetpub\wwwRoot\Auto.mdb")
                  LinksCommand = New OleDBCommand("select * from Links", LinksConnection)
                  LinksConnection.Open()
                  
                  Dim dr As OleDBDataReader = LinksCommand.ExecuteReader()
            
                  dgLinks.DataSource = dr
                  dgLinks.DataBind()
                  
                  
                  LinksConnection.Close()
                  
            End Sub
      
      
            </script>
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <form id="Form1" method="post" runat="server">
                  <asp:datagrid id="dgLinks" style="Z-INDEX: 101; LEFT: 72px; POSITION: absolute; TOP: 72px" runat="server"
                        Height="336px" Width="368px"></asp:datagrid></form>
      </body>
</HTML>
PetiedawgsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JoeisanerdCommented:
the page load event never executes because you have told it to. Change your Page directive from AutoEventWireup=false to true  then it will fire on Page load
ryerrasCommented:
You are doing couple of things wrong here. As Joeisanerd said, you have to put AutoEventWireup to true, but before that, you should change your page directive to the following

<%@ Page Language="vb" AutoEventWireup="true" >

Remember the directive you have is for a typical web form created by Visual Studio.NET. VS.NET uses code behind, but you are not using. So, your application will throw the following parse error message, since thats what you said, to look for the WebForm1 dll, which is generated by the vs.net, if you compile the project using vs.net with your original page directive.

Parser Error Message: Could not load type 'localhost.WebForm1'.

And you AutoEventWireup is important because, that tells your page to look for the typical event handlers for the page events automatically, since you are not wiring up any event handlers in your code

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PetiedawgsAuthor Commented:
Alright I recieved an error now I am finally getting somewhere...here is the error.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Could not find installable ISAM.

Source Error:


Line 18:                   LinksConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDB.4.0;server=localhost;uid=Admin;pwd=;database=C:\Inetpub\wwwRoot\Auto.mdb")
Line 19:                   LinksCommand = New OleDBCommand("select * from Links", LinksConnection)
Line 20:                   LinksConnection.Open()
Line 21:                   
Line 22:                   Dim dr As OleDBDataReader = LinksCommand.ExecuteReader()
 
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

PetiedawgsAuthor Commented:
the error happens at the linksconnection.open()
ryerrasCommented:
This error could be due to so many reasons. First I try to get tehe latest MDAC from microsoft. Then I look at the following article
http://support.microsoft.com/default.aspx?scid=kb;EN-US;283881

Before all this if you do not have a password for your Admin account, please set it to empty string as follows

 LinksConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDB.4.0;server=localhost;uid=Admin;pwd='';database=C:\Inetpub\wwwRoot\Auto.mdb")

If none of this solves, I would go do some googling as this is a very common error
PetiedawgsAuthor Commented:
thanks im working on it!!!
PetiedawgsAuthor Commented:
Man I dont think im going to get too far in this....I have no registry entry for MS Jet 4.0.    I tried reinstalling MS Office to try and get that entry back but i dont have the cd for it.  Im basically stuck in a rock and a hard place.
ryerrasCommented:
did you try putting blank empty string for pwd as i suggested
PetiedawgsAuthor Commented:
Im gonna let this one go and try some other options.  I am actually going to Reimage my computer right now and hope everything gets back in order.  Thanks ryerras and joeisanerd.  I think I can figure it out if i can get the MS Jet registry back in order.  
PetiedawgsAuthor Commented:
Yes I did  I put the blank password.
ryerrasCommented:
ok good luck then. As soon as you finish figuring out, come back and close this question, or if you think any of our comments helped, close it right away, rather than leaving the question open forever
JoeisanerdCommented:
If this is the only problem you are having I think reimaging your machine is bit extreme. Looking at your connection string it doesn't look right. Here is a connection string for accessing an access file that I know works

This is taken straight from a program I made and it's in C#
//Setup Ado connection to it
mdbConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
mdbConnString  += "Data Source="+openFileDialog1.FileName+";";
mdbConnString  += "Password=;User ID=Admin;Jet OLEDB:Database Password=;";
mdbConnString  += "Mode=Share Deny None;Jet OLEDB:Database Locking Mode=1;";

I don't believe that access needs the server= or the database= tag instead use Data Source=
georgeb3Commented:
Howdy.

This may be cheating (but it works for me). Whenever I have a connection string problem, I let the IDE generate the connection string for me, then copy it into my code. Just setup a dummy connection using the ISE and then copy the connection string out of the connection's properties. At least this way you can test it and rule out whether the string itself is the issue.

Also, this won't help your error issue, but you can slightly optimize your code by cutting the datareader object out all together by assigning the LinksCommand.ExecuteReader directly to the dgLinks.DataSource parameter...

  dgLinks.DataSource = LinksCommand.ExecuteReader
  dgLinks.DataBind

At the very least, it's one less object to worry about...just my 2 cents!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.