Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO connectionstring builder 2

Status
Not open for further replies.

SH4F33

Programmer
Apr 1, 2005
58
MU
Is there a way to "invoke" the Data Link Properties that shows up on clicking the "Build" command in the ADODC properties?

Each time I need to create a connectionstring for VB or ASP, I create a connectionstring with ADODC and copy the connectionstring. (I'm a bit lazy. Need some shortcut)

What I'd like to do is to invoke this window and get the connectionstring in a textbox?

Thanks for any suggestions.
 
I saw this on tek-tips, but can't seem to find it again. Please, if you feel inclined to give a star, don't give it to me. I don't deserve it. However, if the original author shows up, he/she deserves it.

Save this file to your windows folder and name it GetConnStr.wsf

Code:
<package>
<job id="GetConnString">
<?job debug="true"?>
<script language="VBScript">
Dim oDataLinks, sRetVal
Set oDataLinks = WScript.CreateObject("DataLinks")
On Error Resume Next    ' trap cancel button
sRetVal = oDataLinks.PromptNew
On Error GoTo 0
If Not IsEmpty(sRetVal) Then    ' didn't click cancel
    InputBox "Your Connection String is listed below.", "OLEDB Connection String", sRetVal
End If
Set oDataLinks = Nothing
</script>
</job>
</package>

You can then create a shortcut on your desktop or run it from the run command. Ex. Start -> Run
Type: C:\Windows\GetConnStr.wsf



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I've covered this in the forum before, but here' a cutdown version that does the job (in VB as opposed to script):

Public Function BuildConnectionString() As String

Dim dataLink As New MSDASC.DataLinks 'Must have reference to Microsoft OLE DB ServiceComponent type library
Dim ConnString As String

' Display the dialog
On Error Resume Next
ConnString = dataLink.PromptNew
If Err = 0 Then
' Create a Connection object on this connection string
BuildConnectionString = ConnString
Else
' User canceled the operation
BuildConnectionString = ""
End If
End Function
 
Thanks to both of u.
I've never played with the OLE DB Service Com.
But I can see that I can let the user change the connectionstring with the PromptEdit. Well, I'll b working on that.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top