Funktion die ein Recordset zurückgibt in VBS?
Hallo,
ich habe unter Folgendem link etwas gefunden was ich so auch in VBS brauche kann mir einer sagen wie ich das machen kann
http://www.supportnet.de/threads/112624/0
Function GetDS(TableName, Criteria)
Dim cnn
Dim strSQL
Dim rc
SQLSRV = "srv125"
SQLDB = "NormanAccess"
SQLUSER = "NormanAccess"
SQLPASS = "norman"
Set cnn = CreateObject("ADODB.Connection")
Set rs2 = CreateObject("ADODB.Recordset")
ConnectionString = "Driver={SQL Server};Server=" & SQLSRV & ";Database=" & SQLDB & ";UID=" & SQLUSER & ";PWD=" & SQLPASS
cnn.ConnectionString = ConnectionString
cnn.Provider = "SQLOLEDB"
cnn.Open
strSQL = "SELECT * FROM " & TableName
If Not IsNull(Criteria) Then
strSQL = strSQL & " WHERE " & Criteria
End If
rs2 = cnn.Execute(strSQL)
If Not IsNull(rs2) Then
Set GetDS = rs2
Else
Set GetDS = Nothing
End If
cnn.Close
Set cnn = Nothing
End Function
Sub test()
Set rs2 = CreateObject("ADODB.Recordset")
rs2 = GetDS("tab_filialliste", "tab_filialliste.ID=" & 6)
rc = MsgBox(rs2!Filialnummer, vbInformation)
End Sub
Antwort schreiben