Daniel,
Project needs to reference the Microsoft OLEDB service component. The code
below is extracted from a button click event. Index 1 is ODBC, Else
displays the standard OLEDB connection dialog.
Matt
Set cnn = New adodb.Connection
If Index = 1 Then
Dim dl As New MSDASC.DataLinks
cnn.ConnectionString = dl.PromptNew
Set dl = Nothing
Else
cnn.Properties("Prompt") = adPromptAlways
'cnn.ConnectionString = '"Provider=SQLOLEDB.1;"
cnn.Open
If Err.Number > 0 Then
Set cnn = Nothing
Exit Sub
End If
End If
strcnn = cnn.ConnectionString
cnn.Close
Set cnn = Nothing
----- Original Message -----
From: "Daniel Magliola" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 02, 2004 1:14 AM
Subject: RE: [vbhelp] Creating an ODBC Source programatically
> Hummmmm...
> I thought it would be an API call, but if it's an ActiveX method, much
> better.
> I'm using ADO for my app.
>
> Thanks
> Daniel
>
> > -----Mensaje original-----
> > De: Unicorn.PC.Support [mailto:[EMAIL PROTECTED]
> > Enviado el: Friday, October 01, 2004 01:31
> > Para: [EMAIL PROTECTED]
> > Asunto: Re: [vbhelp] Creating an ODBC Source programatically
> >
> >
> > Daniel,
> >
> > Do you want the ADO or DAO method?
> >
> > Matt
> >
> > ----- Original Message -----
> > From: "Daniel Magliola" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, October 01, 2004 2:20 AM
> > Subject: RE: [vbhelp] Creating an ODBC Source programatically
> >
> >
> > > Rick,
> > >
> > > Thanks a lot for your answer!
> > > It was very helpful.
> > > I have one more about this.
> > > Do you know if there's an API (or any way, actually) to display the
> > "Manage
> > > ODBC Drivers" screen? I mean the one you usually use in Windows
> > to set-up
> > > ODBC DSNs.
> > >
> > > I've seen a couple of software products display that screen, for the
> > > convenience of the user, so that they don't have to manually navigate
> > there.
> > >
> > > Thanks in Advance
> > > Daniel
> > >
> > > > -----Mensaje original-----
> > > > De: Rick Rose [mailto:[EMAIL PROTECTED]
> > > > Enviado el: Monday, September 27, 2004 15:50
> > > > Para: [EMAIL PROTECTED]
> > > > Asunto: Re: [vbhelp] Creating an ODBC Source programatically
> > > >
> > > >
> > > > This will create an ODBC DSN for an Access database.
> > > >
> > > > Public Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
> > > > (ByVal hwndParent As Long, ByVal fRequest As Long, _
> > > > ByVal lpszDriver As String, ByVal lpszAttributes
> > > > As String)
> > > > As Long
> > > >
> > > > Public Function CreateAccessDSN(DSNName As String, DatabaseFullPath
As
> > > > String) _
> > > > As Boolean
> > > > Dim sAttributes As String
> > > > sAttributes = "DSN=" & DSNName
> > > > sAttributes = sAttributes & "DBQ=" & DatabaseFullPath
> > > > CreateAccessDSN = CreateDSN("Microsoft Access Driver (*.mdb)",
> > > > sAttributes)
> > > > End Function
> > > >
> > > > Public Function CreateDSN(Driver As String, Attributes As String)
> > > > As Boolean
> > > > CreateDSN = SQLConfigDataSource(0&, 1, Driver, Attributes)
> > > > End Function
> > > >
> > > > Public Sub Create()
> > > > Dim blnRetVal As Boolean
> > > > blnRetVal = CreateAccessDSN("DSNName", "C:\myDatabase.mdb")
> > > > End Sub
> > > >
> > > >
> > > > Rick Rose
> > > > -------Original Message-------
> > > >
> > > > From: [EMAIL PROTECTED]
> > > > Date: 09/27/04 11:14:05
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [vbhelp] Creating an ODBC Source programatically
> > > >
> > > > Dear Group:
> > > >
> > > > I've faced this problem several times already, and i've never found
a
> > > > "civilized" solution...
> > > >
> > > > I have to create an ODBC Source programatically. I've seen
> > > > several programs
> > > > do this, they create their own ODBC sources instead of making
> > you create
> > > > them manually, but i've never found the way to do it.
> > > >
> > > > I seriously want to believe there's a better way than manually
writing
> > > > Hard-coded values to the Registry (inside
> > HKLM\Software\ODBC\ODBC.INI).
> > > >
> > > > Does anyone know how to go around doing this?
> > > > I imagine this will be different for every driver. The one i'm most
> > > > interested in is IBM "Client Access" (or "iSeries Access"), but any
> > driver
> > > > will do, it will point me in the right direction at least.
> > > >
> > > > Thanks a lot in advance
> > > >
> > > > Daniel Magliola
> > > > Cimatic SRL
> > > > +5411 4787 5311
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > '// =======================================================
> > > > Rules : http://ReliableAnswers.com/List/Rules.asp
> > > > Home : http://groups.yahoo.com/group/vbHelp/
> > > > =======================================================
> > > > Post : [EMAIL PROTECTED]
> > > > Join : [EMAIL PROTECTED]
> > > > Leave : [EMAIL PROTECTED]
> > > > '// =======================================================
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > .
> > > >
> > > > [Non-text portions of this message have been removed]
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > '// =======================================================
> > > > Rules : http://ReliableAnswers.com/List/Rules.asp
> > > > Home : http://groups.yahoo.com/group/vbHelp/
> > > > =======================================================
> > > > Post : [EMAIL PROTECTED]
> > > > Join : [EMAIL PROTECTED]
> > > > Leave : [EMAIL PROTECTED]
> > > > '// =======================================================
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > > '// =======================================================
> > > Rules : http://ReliableAnswers.com/List/Rules.asp
> > > Home : http://groups.yahoo.com/group/vbHelp/
> > > =======================================================
> > > Post : [EMAIL PROTECTED]
> > > Join : [EMAIL PROTECTED]
> > > Leave : [EMAIL PROTECTED]
> > > '// =======================================================
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> > '// =======================================================
> > Rules : http://ReliableAnswers.com/List/Rules.asp
> > Home : http://groups.yahoo.com/group/vbHelp/
> > =======================================================
> > Post : [EMAIL PROTECTED]
> > Join : [EMAIL PROTECTED]
> > Leave : [EMAIL PROTECTED]
> > '// =======================================================
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
>
>
>
>
> '// =======================================================
> Rules : http://ReliableAnswers.com/List/Rules.asp
> Home : http://groups.yahoo.com/group/vbHelp/
> =======================================================
> Post : [EMAIL PROTECTED]
> Join : [EMAIL PROTECTED]
> Leave : [EMAIL PROTECTED]
> '// =======================================================
>
> Yahoo! Groups Links
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [EMAIL PROTECTED]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/