Page 1 of 1

ASP.NET and Microsoft Access issues

Posted: Mon May 22, 2006 2:09 pm
by erupt
I wasn't sure if this would go under the Misc. section or database section ..... so here it is

I'm currently running Visual Studio 2005 on a Windows XP machine. I'm basically just trying to run a simple script in VB.NET that will allow me to connect to an Access database and display one column on the browser page. The column i'm trying to display is called "email". The code is correct, I'm almost positive about that. It also points to the right directories etc etc. It builds fine. And i'm able to run the code with no errors. Yet all i seem to be able to yield is a blank browser page.
I've tried in both firefox and internet explorer. I'm extremely baffled up to this point. It's probably something very stupid that i'm missing :D
. Here's the code I have in case anyone has any ideas.


--Begin my code --

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Import Namespace="System.Data.OleDb" %>

<html>
<head>
<title>Connecting to a Database using VB</title>
<script runat="server" language="VB">
Sub Page_Load()
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
Dim objRdr As OleDbDataReader

objConn = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;" & _
"Data Source=C:\Inetpub\wwwroot\nestemplate\Database\test.mdb")
objCmd = New OleDbCommand("SELECT * FROM account", objConn)
objConn.Open()
objRdr = objCmd.ExecuteReader()
While objRdr.Read()
Response.Write(objRdr.Item("email"))
End While
objRdr.Close()
objConn.Close()
End Sub
</script>
</head>
<body>

</body>
</html>


--End My Code--

The .mdb file is located in the exact directory as everything else. Any help would be greatly appreciated. :D :D

Posted: Mon May 22, 2006 3:14 pm
by RobertGonzalez
EDIT | Sorry, second answer was stupid, too. Let me think about this for a bit.

EDIT | Apparently I am utterly useless without my .NET book. When I can get my hands on I will look up the code sample that does what you are trying to do and see what the differences are.

Posted: Mon May 22, 2006 5:38 pm
by erupt
Haha, don't even worry about it .. I just randomly decided i was going to get rid of the top line:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

When i got rid of that, it worked. Not sure why.

Posted: Mon May 22, 2006 5:44 pm
by RobertGonzalez
Cool. One less thing for me to do this afternoon. Excellent. Glad it worked out.

Posted: Mon May 22, 2006 6:56 pm
by erupt
No problem. :)