;

ADO ConnectionString Maker for Available DSNs

Using this example, you will create and edit ConnectionStrings based on all availiable DSN and ODBC Driver properties. For example, you can connect to an MS Access Database with 3 different ADO Providers. This code gives you a taste of the many variations of ADO ConnectionStrings that can be arranged with your system's ODBC settings.
Code:


'******************
'YOU NEED:

'VB 6 with:
'Reference Setting checked - "Microsoft OLE DB Service Component
'1.0 Type Library"

'Reference Setting checked - "Microsoft ActiveX
'Data Objects 2.0 Library"


'******************

'STEPS:

'(1)Create EXE project

'(2)Place a long TextBox control named "txtconstr" on form
'[this is your ADO string]

'(3)Place a CommandButton called "cmdNew" on form

'(4)Place a second CommandButton called "cmdEdit" on form

'(5) Insert this code [new]

Private Sub cmdNew_Click()
On Error GoTo ERRORHANDLER
    Dim objDataLink As New DataLinks
    Dim strConn As String

    strConn = objDataLink.PromptNew
    txtConStr.Text = strConn

    Exit Sub
ERRORHANDLER:
    txtConStr.Text = ""
End Sub

'(6)Insert this code [edit]

Private Sub cmdEdit_Click()
On Error GoTo ERRORHANDLER
    Dim objDataLink As New DataLinks
    Dim ADOCN As New ADODB.Connection
    Dim strConn As String

    ADOCN.ConnectionString = txtConStr.Text
    strConn = objDataLink.PromptEdit(ADOCN)
    txtConStr.Text = ADOCN.ConnectionString

    Exit Sub
    
ERRORHANDLER:
     MsgBox "An invalid ADO ConnectionString was detected. Please try again!"
     txtConStr.Text = ""
     
End Sub

No comments:

Post a Comment

Post Comments


Do you have any suggestions ? Add comment. Do not spam!

Search By Google

About this blog

Vision and Mission
Assist each company to improve efficiency and effectiveness to achieve the objectives to serve clients in a professional, objective and sustainable and provide the best solutions for businesses in solving problems in the procurement of informatics and technology.

Excellence
With support from experts and experienced professionals and geared towards fulfilling the needs of clients who put quality in a cost competitif. We also work as partners culter tailored to your company's corporate and can also provide an applicable and practical advice for clients.

New

 

WELCOME

Welcome to the Thomas IPT Blog - Thank you being here, and hope you come back often. Please surf here and read more about the world of computers and various articles of the world that I experienced. There are many things about, you'll probably find something interesting.

ABOUT ME

Working as a Management Information System Design And Development Operations Accounting. Specializing in the manufacture of Retail Database Desktop Applications, ERP / MRP, KSP / KSU, Warehouse, etc by using VB, SQL, Access, Crystal Report

NAVIGASI

SOCIAL STUFF

Info