Define OleDbConnection - what? how? thought it was.

Posted on 2004-11-16
Last Modified: 2008-01-09
I have a form with 3 lablels on it and one text box and one button.
I have made connections to the database using the Data Connection wizzards so now I have an OleDbDataAdapter, OleDbConnection, and DataSet....not sure if that matters but...
When I use the following code in my VB.NET project it underlines OleDbConnection, OleDbCommand  and OleDbDataReader saying "Type OleDbCommand is not defined"
What Do I need to do to define them to get this code to work?


   Dim Connection As OleDbConnection = New OleDbConnection(YourConStr)
        Dim Command As OleDbCommand = New OleDbCommand("SELECT SocSecNo FROM CustomerMaster WHERE SocSecNo='" & txtSocNo.Text & "' AND LastActiveDate BETWEEN '" & Now() & "' AND '" & Now() - 5, Connection)
        Dim DataReader As OleDbDataReader

        DataReader = Command.ExecuteReader
        If DataReader.Read() Then
            'Data Found Display in Labels here
            lblFirstName.Text = DataReader("FirstName")
            lblLastName.Text = DataReader("LastName")
            lblSoc.Text = DataReader("SocSecNo")
            'No data for the Particular Social ID
            'Either Empty the labels or leave it as it is
            lblFirstName.Text = ""
            lblLastName.Text = ""
            lblSoc.Text = ""
        End If
Would this be my connection string (YourConStr)

        Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Registry Path=;Data Source=""C:\Program Files\My APP\DlrData.mdb"" & _
        ";Jet OLEDB:System database=;Jet OLEDB:Global Bulk Transactions=1;Jet OL" & _
        "EDB:Don't Copy Locale on Compact=False;User ID=Admin;Provider=""Microsoft.Jet.OLE" & _
        "DB.4.0"";Jet OLEDB:Database Locking Mode=0;Jet OLEDB:SFP=False;Jet OLEDB:Encrypt " & _
        "Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Compact Without " & _
        "Replica Repair=False;Jet OLEDB:Global Partial Bulk Ops=2;Mode=Share Deny None;Ex" & _
        "tended Properties=;Jet OLEDB:Engine Type=4"
Question by:Matrix1000
    1 Comment
    LVL 24

    Accepted Solution

    You need to add the line Imports System.Data.OLEDb at the very beggining of your code.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now