473,396 Members | 2,014 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,396 software developers and data experts.

Create Access ODBC DSN ?

Hi all.

I've been searching all over the place for a bit of VB Net code that will
create a DSN for an Access database. I've found examples of creating
connections for SQL, but not Access.

Has anyone done this or acn anyone point me in the right direction?

Cheers,
Tull.
Jan 26 '06 #1
3 9461
They keywords should be documented in the help file of the ODBC Access
driver, but you can always create a DSN manually and then get the
keywords/values from the registry:

For system DSNs:

HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI

At minimum, the DSN for access requires the DBQ=myAccessFile.mdb
keyword/value if I recall correctly.

Notice also that you can skip the creation of a DSN and use a DSN-less
connection, adding the "Driver={Microsoft Access Driver (*.mdb)"
keyword/value. Search the DSN-less concept in Google.
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com

"Tull Clancey" <tu**********@btopenworld.com> escribió en el mensaje
news:dr**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
Hi all.

I've been searching all over the place for a bit of VB Net code that will
create a DSN for an Access database. I've found examples of creating
connections for SQL, but not Access.

Has anyone done this or acn anyone point me in the right direction?

Cheers,
Tull.

Jan 26 '06 #2
On Thu, 26 Jan 2006 13:41:44 +0000 (UTC), "Tull Clancey" <tu**********@btopenworld.com> wrote:

¤ Hi all.
¤
¤ I've been searching all over the place for a bit of VB Net code that will
¤ create a DSN for an Access database. I've found examples of creating
¤ connections for SQL, but not Access.
¤
¤ Has anyone done this or acn anyone point me in the right direction?

I don't really recommend that you use the MS Access ODBC driver (use Jet OLEDB instead), but the
below thread (my second post) should demonstrate how:

http://makeashorterlink.com/?F2555184B
Paul
~~~~
Microsoft MVP (Visual Basic)
Jan 26 '06 #3
' Declare this in your Declarations

Public Declare Auto Function SQLConfigDataSource Lib
"ODBCCP32.DLL" _
(ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal
lpszDriver As String, ByVal lpszAttributes As String) As Long

'
-----------------------------------------------------------------------------------
Private Sub ConfigureODBC

Dim sDriver = "Microsoft Access Driver (*.mdb)"
Dim sAttributes As New System.Text.StringBuilder
Const ODBC_ADD_SYS_DSN = 4
Dim intResult As Long

sAttributes.Append("DSN=My DSN Name")
sAttributes.Append(Chr(0))
sAttributes.Append("DBQ=")
sAttributes.Append(strDatabasePath)
sAttributes.Append("\MyDB.mdb")
sAttributes.Append(Chr(0))
sAttributes.Append(Chr(0))

intResult = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, sDriver,
sAttributes.ToString)

sAttributes = Nothing
end Sub

Jan 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
9
by: Albretch | last post by:
.. I am trying to create a database in a MS Access DB via JDBC drivers. I have tried both sun.jdbc.odbc.JdbcOdbcDriver and ids.sql.IDSDriver From some reason both drivers Exceptions tell me...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
1
by: Bruce Lawrence | last post by:
I know this works for Access 97. Not sure about other versions. This will create a DSN to a SQL server in your ODBC connections and then link a table of your choise from that SQL DB to the...
4
by: Paul | last post by:
Hi, I am developing a c# windows .NET application. The application is going to run on a standalone PC and use an access database. I have figured out that I will need to create a project and add it...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
3
by: hsalort | last post by:
Hi, My question es very simple: Can I create a ADP file in MS Access 97 for updating tables, views, functions and stores procedures for a SQL Server database in a remote server. I'm using...
0
by: Greg Corradini | last post by:
Hello, Lately I've been using the mx.ODBC module to query Access (mdb) tables. For the life of me, I can't get the 'create table' sql command to work. I use this command in Oracle and I've seen...
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: 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
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
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...
0
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...

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.