JustCode : Delete a vdata record

This sub shows us how to delete a vdata record from a survey. It has 3 parms that you need to pass in. You will also need to enter a valid SQL user login & password.

 
' sSurvey: The name of the survey that is to be used.
' sID: The Respondent.serial that is to be deleted.
' sServer: The name or the IP of the SQL server
' ****************************************
' Designed by : Smarter Dimensions
' Last Updated : 8th July 2009
' Sub to delete a vdata record
' ****************************************

Sub DeleteVDataRecord(sSurvey,sID,sServer)

    Set oConnection = CreateObject("ADODB.Connection")

    oConnection.ConnectionString = "Provider=mrOleDB.Provider.2;Data Source=mrRdbDsc2;Location='Provider=SQLOLEDB.1;Password=XXXXXX;Persist Security Info=True;User ID=XX;Initial Catalog=" + sSurvey + ";Data Source=" + sServer + "';Initial Catalog=\" + sServer + "SPSSMR_FMROOTMaster" + sSurvey + "" + sSurvey + ".mdd;MR Init Project=" + sSurvey

    oConnection.Open()

    If ( oConnection.State = 1 ) Then

        Set oRecordset = CreateObject("ADODB.Recordset")
        oRecordset.Open("DELETE FROM VDATA WHERE Respondent.serial = '" + sID + "'" ,oConnection,3,1)
        Set oRecordset = Null

    End If

    oConnection.Close()
    Set oConnection = Null

End Sub

Leave a Comment