473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to connect to access db file from VS2020 (can't find System.Data.OleDb)?

Hello
I have been programming vba for some time and am now starting VB.NET. I need to connect to an existing access db file (access 2003). I downloaded VS2010 and found an example on the net. Here is most of the code:
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2. Public Class Form1 Inherits System.Windows.Forms.Form
  3.     Dim cn As OleDbConnection
  4.     Dim cmd As OleDbCommand
  5.     Dim dr As OleDbDataReader
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.     End Sub
  8.  
  9.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  10.         Try
  11.             cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\emp.mdb;")
  12.             'provider to be used when working with access database
  13.             cn.Open()
  14.             cmd = New OleDbCommand("select * from table1", cn)
  15.             dr = cmd.ExecuteReader
  16.             While dr.Read()
  17.                 TextBox1.Text = dr(0)
  18.                 TextBox2.Text = dr(1)
  19.                 TextBox3.Text = dr(2)
  20.                 ' loading data into TextBoxes by column index
  21.             End While
  22.  
I am getting this error message:
1 End of Statement Expected

I have tried to add a reference to System.Data.OleDb but
it doesn't appear in the add reference box. System.Data.OleDb is checked in the Imported namespaces window. I have tried changing the .NET Framework but, no help. Help would be greatly appreciated.

Thank you

John
Dec 9 '10 #1
1 1919
Hello
After taking another look I noticed that the error refered to line 2, which is:

Public Class Form1 Inherits System.Windows.Forms.Form

I erased everything from "Inherits" to the end of the line, now it is:

Public Class Form1

The example code now works. Why, I don't know. Do you?

John
Dec 13 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: silesius | last post by:
I've been using VS 2003 to develop a webapplication using C#. Today I exported the application to a remote webserver I begun experiencing problems. It's a simple application that retrieves some...
2
by: SpotNet | last post by:
Hello Newsgroup, Started a job where an Access 2003 database is accessed with a custom assembly that wraps\encapsulates the relevant System.Data.OleDb classes needed for the application. Briefly...
2
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
0
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
3
by: Sarah | last post by:
I have a function residing in a module that is doing some file copy and database query operations. This function is called from a regular form under a System.Windows.Forms.Timer control. The...
2
by: bokiteam | last post by:
Hi All, I am reading data from database, I can use SQL command set to get data. now I wan to use the same function in WINCE, but I can't find "system.data.oledb" in SmartDevice developing...
2
by: George | last post by:
Hello everyone, I have used Visual Studio 2005 to create a C# .Net Compact Framework 1.0 application on Pocket Pc 2003 device. But when building the application, there are some errors dealing...
0
by: RN | last post by:
Hi everyone, First please let me explain. I am attempting to store pdf files in an MS Access DB (2000) and I have written a subroutine to do this. My code seems to work perfectly (see code...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.