473,782 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

connecting visual basic with ms access database

1 New Member
Hi !

I want to know the connection code for connecting visual basic and microsoft access. plese give the detail code for this connection. Actually I tried one code which is as follows:

Dim cn as connection
Dim rs as recordset

Private Sub form()
set cn = new connection
set rs = new recordset

cn.open ="Provider Microsoft Access OLEDB jet4.0, database.mdb"
rs.open"([source],cn,adlockoptim istic,adcmdtext )"

End Sub

I am getting error for the above code as "expected =" after 'rs.open'.

Can u please provide me with the correct code as soon possible?

Waiting for reply

Thanks
Jayanti
Mar 12 '08 #1
2 1606
jamesd0142
469 Contributor
What version of vb are you using?
Mar 12 '08 #2
pureenhanoi
175 New Member
Hi !

I want to know the connection code for connecting visual basic and microsoft access. plese give the detail code for this connection. Actually I tried one code which is as follows:

Dim cn as connection
Dim rs as recordset

Private Sub form()
set cn = new connection
set rs = new recordset

cn.open ="Provider Microsoft Access OLEDB jet4.0, database.mdb"
rs.open"([source],cn,adlockoptim istic,adcmdtext )"

End Sub

I am getting error for the above code as "expected =" after 'rs.open'.

Can u please provide me with the correct code as soon possible?

Waiting for reply

Thanks
Jayanti
the statement Rs.Open is invalid gramma
it must be: rs.Open "[Source]", cn, adOpenStatic, adLockOptimisti c, adCmdText

and the connection String of cn is invalid too. I'm not sure can it work without correcting, but you must use this:
Cn.Open "Provider=Microsoft.Jet.O ledb.4.0; Data Source=C:\database.mdb;"
Mar 13 '08 #3

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

Similar topics

3
6107
by: Krish | last post by:
Hi Friends, Does anyone know how to connect access database into Visual C++ in Visual Studio 6.0. I know the procedure to connect access database into Visual Studio .Net. But Visual Studio 6.0 is more complicted than .Net. Can someone help me pls? Thanks Krish
1
254
by: Mohammad-Reza | last post by:
It is now 3 months that we are trying to connect ASP.NET to a SQLServer located on another system However we act,we get a fatal error We need someone to explain the way of connecting to SQLServer step by step from either VisualStudio.NET or FrontPage 2003 Our goal is to retrieve records from SQLServer and display them in ASP.NET pages,edit them,and return them to SQLServer Thanx in advance.
2
1114
by: jrbrady | last post by:
I am configuring a SQLDataAdapter using the Data Adapter Configuration Wizard. I click New Connection. I select my server name, user name and password, and the database name. I test the connection. It works. I click Ok and am asked for the password again. I enter it, and click ok. I receive the following message: "Unable to connect to database. It is only possible to connect to SQL Server Desktop Engine databases and Microsoft...
1
3372
by: ben_chicago | last post by:
I JUST INSTALLED Visual Basic.NET BUT, CANNOT CONNECT TO MY AS/400 (OS400 5.1). WHEN I TRY TO CONNECT I GET A SERVER EXPLORER MSG: "UNABLE TO CONNNECT TO DATABASE. IT IS ONLY POSSIBLE TO CONNECT TO SQL SERVER DESKTOP ENGINE DATABASES AND MICROSOFT ACCESS DATABASES WTIH THIS VERSION OF VISUAL STUDIO." -What Version Of Visual Studio do I need?
1
1267
by: Dibs | last post by:
Hi, is there anyway of telling what type of database I'm connecting to? we've upgraded a product to vb.net so its using ADODB and ODBC. The database is going to be either Access, SQLServer or Oracle. The only thing I've come up with so far is to check the registry for the driver but I can't be sure what ODBC driver they'll use. Any Clues? Thanks
11
2055
by: CM Manager via DotNetMonster.com | last post by:
I am very frustrated due to this exception error I am receiving. I've tried searching numerous user support groups, Microsoft Support Net, Google, etc. and haven't found exactly my situation. Hopefully someone here can help. I am just learning VB.NET and purchased the SAM's "Teach Yourself VB.NET 2003 in 21 days' book. I am trying to connect to an Access database I created locally on my computer per Chapter 16. I originally had it on a...
4
7570
by: kthiagar | last post by:
Hi I am trying to connect to a password protected access file from VB.NET. I have no problem in connecting to Access, if I remove the password. This is what I am doing: In the server explorer, I choose "Add a connection" Choose "Microsoft Jet 4.0 OLEDB Provider" in the provider tab Selected the access file in the next tab Left Username as Admin and typed the password. Now when I try to test connection, I am getting this error message:
2
2091
by: CAM | last post by:
Hello, I am wondering if someone can give me some pointers. Currently I am using Access 2002 I developed an inventory tracking database, which this database is used in California and in Florida. Unfortunaley Access is not very good as an enterprise wide database, accessing the data from one side of the United States to the other its so slow. About 5 years ago I developed a database using Visual Basic 6 as the front end and Crystal...
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.