Subject: Chapte2 DataControl.aspx
Posted By: frogfur Post Date: 2/11/2004 4:09:32 PM
This is a problem in Chapter 2 of ASP.NET with VB.NET

This is the Code, I have added debug after it says to when I get the error message.  

<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.OleDb" %>
<%@ Page Language="vb" Debug="true" %>

<script language="vb" runat = "server">

Sub Page_Load(Sender as Object, E as EventArgs)

    Dim objConnection As OleDbConnection
    Dim objCommand As OleDbDataAdapter
    Dim strConnect As String
    Dim StrCommand As String
    Dim DataSet1 As New DataSet

    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;"
    strConnect += "Data Source=C:\Program Files\Microsoft.NET\FrameworkSDK\"
    strConnect += "Samples\quickstart\aspplus\samples\grocertogo\data"
    strConnect += "\grocertogo.mdb;"
    strConnect += "Persist Security Info=False"
    
    strCommand = "SELECT ProductName, UnitPrice FROM products"
    objConnection = New OleDbConnection(strConnect)
    objCommand = New OleDbDataAdapter(strCommand, objConnection)
    objCommand.Fill(DataSet1,"products")
    DataGrid1.DataSource=DataSet1.Tables("Products").DefaultView
    DataGrid1.DataBind()
End Sub

</script>
<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server" />
</body>
</html>


Now I get the Error Message:
Server Error in '/BegASPNET' Application.
--------------------------------------------------------------------------------

'C:\Program Files\Microsoft.NET\FrameworkSDK\Samples\quickstart\aspplus\samples\grocertogo\data\grocertogo.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
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: 'C:\Program Files\Microsoft.NET\FrameworkSDK\Samples\quickstart\aspplus\samples\grocertogo\data\grocertogo.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

Source Error:


Line 22:     objConnection = New OleDbConnection(strConnect)
Line 23:     objCommand = New OleDbDataAdapter(strCommand, objConnection)
Line 24:     objCommand.Fill(DataSet1,"products")
Line 25:     DataGrid1.DataSource=DataSet1.Tables("Products").DefaultView
Line 26:     DataGrid1.DataBind()
 

Source File: C:\BegASPNET\Ch02\groceries.aspx    Line: 24


I get the same error when I run the one from the download that I got from wrox books.

Has anyone else had this same problem?

Do I need to change the connection path?
If so, How did you fix it?


Go to topic 9692

Return to index page 950
Return to index page 949
Return to index page 948
Return to index page 947
Return to index page 946
Return to index page 945
Return to index page 944
Return to index page 943
Return to index page 942
Return to index page 941