data ind i mysql via vbscript
hejsaJeg har følgende VBS som skulle opdater min mysql men der kommer sku ikke noget data indi databasen! kan i se nogle fejl!
i kan se det andet spgøsmål hvor det også indgik:
http://www.eksperten.dk/spm/529355
og vbsciptet har jeg fået her fra:
http://www.topcatcomputing.com/articles/displayarticle.asp?DocId=21
Option Explicit
Dim StrCn, oConnection, strFilterName,Count, Rs, SQL, sdate
' Connection String.
' NOTE: You must replace DataBase, User and Password with the appropiate values
' for your Server.
strCn = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; "
strCn = strCn & "DATABASE=spamstats; USER=********; PASSWORD=*********; Option=35;"
If WScript.Arguments.Count = 1 Then
strFilterName = WScript.Arguments.Item(0)
Set oConnection = CreateObject("ADODB.Connection")
Set Rs = wscript.CreateObject("ADODB.Recordset")
oConnection.Open strCn
Rs.ActiveConnection = oConnection
Rs.Open ("SELECT FilterName, HitCount FROM stats WHERE FilterName = '" & strFilterName & "'")
If Rs.EOF Then
SQL= "INSERT INTO stats (FilterName, HitCount) VALUES ('" & strFilterName & "', 1)"
oConnection.Execute SQL
Else
SQL="UPDATE stats Set HitCount =" & Rs("HitCount") + 1 & " WHERE FilterName = '" & strFilterName & "'"
oConnection.Execute SQL
End If
sdate=GetDate()
' This next line is optional. It is used to hold the current time stamp, each
' time the script is run.
oConnection.Execute "UPDATE CONFIG Set KeyValue='" & sdate & "' where ID=1"
oConnection.Close
End If
' ==============================================================================================
' Function GetDate()
' Gets the Current Date and time and fomates it the correct format.
' ==============================================================================================
Function GetDate()
' This function will take the current date & time and format it into a time stamp
Dim TempDay, TempMonth, TempYear
TempDay= DatePart("d", Now)
TempMonth= DatePart("m", Now)
TempYear= DatePart("yyyy", Now)
If TempDay < 10 Then
TempDay= "0" + TempDay
End If
Select Case TempMonth
Case 1 TempMonth = "January"
Case 2 TempMonth = "February"
Case 3 TempMonth = "March"
Case 4 TempMonth = "April"
Case 5 TempMonth = "May"
Case 6 TempMonth = "June"
Case 7 TempMonth = "July"
Case 8 TempMonth = "August"
Case 9 TempMonth = "September"
Case 10 TempMonth = "October"
Case 11 TempMonth = "November"
Case 12 TempMonth = "December"
End Select
GetDate=TempDay &" " & TempMonth & " " & TempYear & " @ " & FormatDateTime(Now, 4)
End Function