Another Dumbass Question: Table not found

  • Thread starter Thread starter Child
  • Start date Start date
C

Child

Sadly, I am learning this using Access, no cracks please, its certainly not my
preference:

I am attempting to connect to the database using OLEDB, but it returns that the table
cannot be found. The table is there and the name is correct. Several other tables yeild
the same results. Is there some bizarre permissions issue whereby the OLE stuff can't
see the tables unless I do something?

DBConn= New OLEDBConnection( _
"PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE= e:webdatabase
\apca_contact_data.mdb;")

DBCommand = New OleDBDataAdapter _
("Select Username, UserID from tblAPCAUsers order by username", DBConn)



Thanks in advance.
 
The code example below is a VB.NET example of connecting to Access, give it
a try and see if you get the same results as the code looks very similar to
what you are trying to accomplish. It may be that your directory does not
have write permissions and cant actually open the DB, however as you dont
suggest its failing anywhere, only not finding a table that does exist then
that might have nothing to do with it.

On first sight, your code looks OK but do a comparison with the code I have
added below and see if you can spot a problem.

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

<%@ Page Language="VB"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
Sub Page_Load(Src as object, E as EventArgs)

Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String


objConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("database.mdb") & ";")

strSQLQuery = "SELECT * FROM sample "

objCommand = New OleDbCommand(strSQLQuery, objConnection)

objConnection.Open()

objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection)

resultsGrid.DataSource = objDataReader
resultsGrid.DataBind()

End Sub

</script>

<html>
<body>



<asp:DataGrid id="resultsGrid" runat="server"
cellspacing="1"
cellpadding="2"
HeaderStyle-Font-Bold="True"
ToolTip="This is Cool!"
MaintainViewState="false"
/>

</body>
</html>
 
John, thanks much. I am a moron (i.e i got it)

I have cut and pasted your code, cause its prettier than mine. <vbg>
--
BethF, Anchorage, AK

It's YOUR God.
They are YOUR rules.
YOU burn in hell.
 
Glad to have helped :0)

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 
Back
Top