|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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. 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. -- Show quoteHide quoteBest 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" <tull.clan***@btopenworld.com> escribió en el mensaje news:drajio$if9$1@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. > On Thu, 26 Jan 2006 13:41:44 +0000 (UTC), "Tull Clancey" <tull.clan***@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) ' 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
DataGridView: Preventing deselection of a selected checkbox
Form Focus Issue Best way to do a connection-oriented Send/Receive. Syntax not accepted on my version of VS why ?. need ideas - caching strategy RS 2005: Use a Custom Class as DataSource? Datareader binding to datagrid not working beta 3 what is the MyApplication.vshost.exe? New 2 dotnet but Im a vb6 programmer |
|||||||||||||||||||||||