ASP.NET and Microsoft Access issues

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
erupt
Forum Commoner
Posts: 58
Joined: Sat Feb 25, 2006 10:24 am

ASP.NET and Microsoft Access issues

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
erupt
Forum Commoner
Posts: 58
Joined: Sat Feb 25, 2006 10:24 am

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Cool. One less thing for me to do this afternoon. Excellent. Glad it worked out.
erupt
Forum Commoner
Posts: 58
Joined: Sat Feb 25, 2006 10:24 am

Post by erupt »

No problem. :)
Post Reply