Why is there a comma on the second line here:
pField:= pFields.Item(A_Index-1) , sData .= pField.Name . ": " . pField.Value . "`r`n"Is AHK_L's handling of COM more efficient? As in, faster for big searches, etc?
And now the issue that I really need addressed... How can I extract a file from inside an SQL database? It is stored as an 'image' type. I need to query that information out, and write it back as the same file. That can be a *.doc, *.xls, *.tif, etc. I imagine whatever routine would be able to write it as a file and if it has the right extension it will come up fine.
Is this something anyone can help me with this in AHK_L?
Here is my attempt at coding this:
Parse = "," ParseComma = , ParseQuote = " ParseEnd = "`r`n sQuery := "SELECT * FROM " . "atlas" . " WHERE country LIKE 'A%'" sConnect := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . "C:\Database\atlas.mdb" SQL_L_SaveToFile(sQuery, sConnect, SaveFileNameIndex = "1", SaveFileValueIndex = "2") ; 04/07/2011 { Global Parse, ParseComma, ParseQuote, ParseEnd prs := ComObjCreate("ADODB.Recordset") prs.Open(sQuery, sConnect) While !prs.EOF { pFields := prs.Fields Loop, % pFields.Count { pField:= pFields.Item(A_Index-1) MsgBox, % "Debug:`nValue:`n" . pField.Value If A_Index = 1 { HeaderRow := pField.Name WriteRecord := pField.Value } Else { HeaderRow .= Parse . pField.Name WriteRecord .= Parse . pField.Value } If A_Index = %SaveFileNameIndex% FileName := RegExReplace(pField.Value, "/", " or ") If A_Index = %SaveFileValueIndex% { pmstream.ActiveXObject("ADODB.STREAM") ;Create and open a binary stream pmstream.Type(adTypeBinary) pmstream.Write(pField.Value) FileContents := pField.Value Count = 1 Loop { Count++ If A_Index = 1 FileNameMod := FileName IfExist, %FileNameMod% { SplitPath, FileName, , , FileNameExt, FileNameNoExt FileNameMod := FileNameNoExt . " (" . Count . ")." . FileNameExt } Else Break } pmstream.SavetoFile(FileNameMod, 1) ; COM_Invoke(pField, "SavetoFile", FileNameMod, adSaveCreateOverWrite) } } prs.MoveNext() HeaderRow := ParseQuote . HeaderRow . ParseEnd Data .= ParseQuote . WriteRecord . ParseEnd RecordCount := A_Index ;MsgBox, Debug:`nRecordCount: %RecordCount%`n`nHeaderRow: %HeaderRow%`n`nWriteRecord:`n%WriteRecord%`n`nData:`n%Data% ; For testing, enabled } prs.Close() Result := HeaderRow . Data Return Result }