473,388 Members | 1,426 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,388 software developers and data experts.

To join Ms-Access to VB try to write my code please help me

38
Hi all

i could not joine MS Access table to VB the code i write below

Private Sub Form_Load()
Set cn = New ADODB.connection
cn.Provider = "Microsoft.jet.oledb.4.0"
cn.Open "C:\db1.mdb"
Set rs = New ADODB.Recordset
rs.Open "tbl", cn, adOpenDynamic, adLockOptimistic
Show
Call DisplayTheCurrentRecord
End Sub


My Database name is db1 and table name tbl.

Please help me.
Feb 4 '08 #1
5 1581
debasisdas
8,127 Expert 4TB
what is the error message ?

try to use this sapmle for referrence for connection string

cn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\biblio.mdb;Persist Security Info=False
"
Feb 4 '08 #2
Hi all

i could not joine MS Access table to VB the code i write below

Private Sub Form_Load()
Set cn = New ADODB.connection
cn.Provider = "Microsoft.jet.oledb.4.0"
cn.Open "C:\db1.mdb"
Set rs = New ADODB.Recordset
rs.Open "tbl", cn, adOpenDynamic, adLockOptimistic
Show
Call DisplayTheCurrentRecord
End Sub


My Database name is db1 and table name tbl.

Please help me.

you have to change
rs.Open "select * from tbl", cn, adOpenDynamic, adLockOptimistic
Feb 4 '08 #3
dnb
34
First add 'Microsoft ActiveX Data objects library 2.0' from references
First Save your project and database in the same folder.


Public cn As ADODB.Connection

Private Sub Form_Load()

Set cn = New ADODB.Connection
cn.Provider = "Microsoft.jet.oledb.4.0;"
cn.ConnectionString = App.Path & "/db1.mdb"
cn.CursorLocation = adUseClient
cn.Open

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
If rs.State = 1 Then rs.Close
rs.Open "select * from tbl", cn, adOpenDynamic, adLockOptimistic

End Sub
Feb 4 '08 #4
alem
38
Alem
I Thank U all I have got my answer
I appreciate your help.

Thanks again.
Feb 4 '08 #5
debasisdas
8,127 Expert 4TB
you have to change
rs.Open "select * from tbl", cn, adOpenDynamic, adLockOptimistic
not necessary

it can be any sql query, table ,view or materialized view name also.
Feb 4 '08 #6

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

Similar topics

2
by: Bruce Duncan | last post by:
I'm a bit new to MySQL (know MS SQL well...and that may be the problem...getting the syntax confused) and I'm having a join problem...can anyone offer some help? Here's my problem: I have table1...
2
by: Bruce Duncan | last post by:
I'm a bit new to MySQL (know MS SQL well...and that may be the problem...getting the syntax confused) and I'm having a join problem...can anyone offer some help? Here's my problem: I have table1...
21
by: CSN | last post by:
I have a pretty simple select query that joins a table (p) with 125K rows with another table (pc) with almost one million rows: select p.* from product_categories pc inner join products p on...
4
by: Michael Fuhr | last post by:
I have a query that works in 7.3.6 but not in 7.4.2 unless I turn off enable_hashjoin. I'm joining a table of network interfaces and a table of networks so I can find additional info about a...
4
by: Brian Parker | last post by:
I'm new to ms-sqlserver ( 2000 ) and need to get an OUTER JOIN working on a three table query. Assumptions: -- I have events in the Event table. -- Each event CAN have one Transaction, but it's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.