Loxias
09-08-2005, 07:28 PM
Alright, I've written a script that searches network machines and polls the computer for all the mp3s on a machine. It outputs the results to an html file as a report. Works great (albeit a little slow) so now my manager wants reports more often. To combat this I figured I'd have it write to a database and then he can query what he wants. Great idea but I've got a couple of snags...
I'll paste the code below but basically I've been able to attach to the database and write the username and computer name to their tables. The problem I'm having is getting the file info to write to it's table. Here's the code and then I'll explain what I've done
'*Establish connection with database
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=MediaSearch;"
'*Get computer name and store in database
strComputer = objDictionary.Item(objItem)
objRecordset.CursorLocation = adUseClient
strSQLQuery = "INSERT INTO computer (compname) VALUES ('"& strComputer &"')"
objRecordset.Open strSQLQuery , objConnection, _
adOpenStatic, adLockOptimistic
'*Store user in database
strSQLQuery = "INSERT INTO user (username) VALUES ('"& strValue &"')"
objRecordset.Open strSQLQuery , objConnection, _
adOpenStatic, adLockOptimistic
'*Store file info in database
strSQLQuery = "INSERT INTO test (filename) VALUES ('"& scanfilename &"')"
objRecordset.Open strSQLQuery, objConnection, _
adOpenStatic, adLockOptimistic
That's snippets of how I'm inserting the values. I've verified that the filename value is populated before the query is run but I still don't get the value in the database. That query is actually scaled down for testing because I obviously want more info than just the file name. When I was trying to put all info I thought maybe it was the backslashes in the filepath that was causing the issue but the small version doesn't work either. Any suggestions on where to go from here is greatly appreciated.
Thanks
I'll paste the code below but basically I've been able to attach to the database and write the username and computer name to their tables. The problem I'm having is getting the file info to write to it's table. Here's the code and then I'll explain what I've done
'*Establish connection with database
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=MediaSearch;"
'*Get computer name and store in database
strComputer = objDictionary.Item(objItem)
objRecordset.CursorLocation = adUseClient
strSQLQuery = "INSERT INTO computer (compname) VALUES ('"& strComputer &"')"
objRecordset.Open strSQLQuery , objConnection, _
adOpenStatic, adLockOptimistic
'*Store user in database
strSQLQuery = "INSERT INTO user (username) VALUES ('"& strValue &"')"
objRecordset.Open strSQLQuery , objConnection, _
adOpenStatic, adLockOptimistic
'*Store file info in database
strSQLQuery = "INSERT INTO test (filename) VALUES ('"& scanfilename &"')"
objRecordset.Open strSQLQuery, objConnection, _
adOpenStatic, adLockOptimistic
That's snippets of how I'm inserting the values. I've verified that the filename value is populated before the query is run but I still don't get the value in the database. That query is actually scaled down for testing because I obviously want more info than just the file name. When I was trying to put all info I thought maybe it was the backslashes in the filepath that was causing the issue but the small version doesn't work either. Any suggestions on where to go from here is greatly appreciated.
Thanks