Thursday, March 22, 2012

OleDbConnection is not defined.

Hi!
I get the following error when connecting to my database. What am I missing? Please help, its driving me crazy!

Compiler Error Message:BC30002: Type 'OleDbConnection' is not defined.
Source Error:
Line 10: Dim objConnection As OleDbConnection

This is my code:
<%@dotnet.itags.org. Page Language="VB" %>
<%@dotnet.itags.org. import Namespace="System" %>
<%@dotnet.itags.org. import Namespace="System.Data" %>
<%@dotnet.itags.org. import Namespace="Sysyem.Data.OleDb" %>
<script runat="server">
    Sub Page_Load(Source As Object, E As EventArgs)
Dim objConnection As OleDbConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=C:\..\foods.mdb")
objConnection.Open()
...
Add this to the top of you code behind page...

Imports System.Data.OleDb

Oopps, just looked closer at your code... nevermind.
You must not be using VS.Net.
You have it imported and it should work.

Zath


Nope, no VS.NET for me! I'm using webmatrix. I thought it should work, is there something I could be leaving out - like setting it up through ODBC administrator?
Crab


Crab wrote:

This is my code:
<%@. Page Language="VB" %>
<%@. import Namespace="System" %>
<%@. import Namespace="System.Data" %>
<%@. import Namespace="Sysyem.Data.OleDb" %>


You've misspelled the namespace. Try
System.Data.OleDb

Good catch. I didn't even notice that.....
Doh! I can't believe how many times I read over that and didn't see it. Thanks!
Doh! I can't believe how many times I read over that and didn't see it. Thanks!
Now I have a problem with my datareader! any more help?
Compiler Error Message:BC30201: Expression expected.
Source Error:
Line 22: & "</b></td><td>" & objDataReader("Weight") & "</td><td>" _Line 23: & objDataReader("Price") & "</td></tr>" & _Line 24: & "<tr><td colspan='3'>" & objDatareader("Description") _Line 25: & "</td></tr>"Line 26: Loop

Did you check whether you have null values into your Description column? Another way is allowing null values against that column

There are no null values in any of the columns used. I can't work it out.


Can we see more of your code? I am curious why you are outputting your data in that manner.

S'ok, it was an extra & at the end of line 23. I'm doing an exercise from as asp.net book that was using the datarepeater to display the datasource.
Thanks for your help!

0 comments:

Post a Comment