I'm having trouble accessing data from an access database. I'm used to database interactions using asp 3.0. I'm using some code that was provided by "pvb" in this thread:
http://vbforums.com/showthread.php?t...ccess+database
But, none of the data is being displayed on the page. Here is the code as I have implemented it.
I don't get any errors or anything, I just see a blank page when I load it. Shouldn't the data from my database appear in the datagrid when the page is loaded?
Thanks for any help!
VB Code:
Imports System.Data Imports System.Data.OleDb Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents gridAuthors As System.Web.UI.WebControls.DataGrid #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If Not Page.IsPostBack Then bindAuthors() End If End Sub Protected Sub bindAuthors() Dim mdbPath As String = "G:\WebServer\cpthandler\database\cptDataInfo.mdb" Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbPath Dim cn As New OleDbConnection(connString) Dim cmdText As String = "SELECT CONTACT_NAME FROM cptDataInfo" Dim cmd As New OleDbCommand(cmdText, cn) cmd.Connection.Open() gridAuthors.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection) gridAuthors.DataBind() End Sub End Class
Here's the html source:
I don't get any errors or anything, I just see a blank page when I load it. Shouldn't the data from my database appear in the datagrid when the page is loaded?Code:<%@ Page Language="vb" AutoEventWireup="false" Codebehind="createCPTxml.aspx.vb" Inherits="createCPTxml.WebForm1"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form runat="server"> <asp:DataGrid Runat="server" AutoGenerateColumns="True" ID="gridAuthors" /> </form> </body> </HTML>




Reply With Quote