Follow @dporton

JustCode : Connect to a Data Collection Survey

This example shows you how to connect to a Data collection survey via odbc.

This is the required metadata

Metadata(en-AU, Question, Label)
    ConnectionInfo "{Info}" info;
End Metadata

This is the required Routing

Routing(Web)
Dim sProject, sServer, sConnection , sPassword, sUser
Dim oConnection, oRecordset

    sProject = "ADO"
    sServer = "MyServer"
    sUser = "admin"
    sPassword = "abc"

Set oConnection = CreateObject("ADODB.Connection")

    sConnection = "Provider=mrOleDB.Provider.2;Data Source=mrRdbDsc2;"
    sConnection = sConnection + "Location='Provider=SQLOLEDB.1;Password=" + sPassword + ";Persist Security Info=True;User ID="
    sConnection = sConnection + sUser + ";Initial Catalog=" + sProject + ";Data Source=" + sServer
    sConnection = sConnection + "';Initial Catalog=\\" + sServer + "\SPSSMR_FMROOT\Master\" + sProject + ""
    sConnection = sConnection + sProject + ".mdd;MR Init Project=" + sProject

    oConnection.Open(sConnection)

    If ( oConnection.State = 1 ) Then
        ConnectionInfo.Label.Inserts["Info"] = "Connection to the Database worked"
    Else
        ConnectionInfo.Label.Inserts["Info"] = "Connection to the Database failed"
    End If

    oConnection.Close()

    Set oConnection = Null
    ConnectionInfo.Show()

End Routing
%d bloggers like this: