Ace08 Posted May 20, 2011 Share Posted May 20, 2011 (edited) Hi again i found a script that ptrex made, it was originaly made to read an excel file as a database and counting all the records. what i did was query all the records however i can only get only one column record. this one works. expandcollapse popupConst $adOpenStatic = 3 Const $adLockOptimistic = 3 Const $adCmdText = 0x0001 Global $s_Filename=FileGetShortName("D:\My Documents\PROGRAMS\DataBase Update\8082009-042011.xls") Global $s_Tablename = "[Sheet1$]" ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Source XLS data $objConnection = ObjCreate("ADODB.Connection") $objRecordSet = ObjCreate("ADODB.Recordset") $objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source="&$s_Filename&";" & _ "Extended Properties=""Excel 8.0;HDR=Yes;"";") $objRecordSet.Open ("Select CustomerID FROM "& $s_Tablename , $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText) Do ConsoleWrite ($objRecordSet.Fields(0).value & $objRecordSet.Fields(1).value & @CR) $objRecordSet.MoveNext() Until $objRecordSet.EOF() $objConnection.Close $objConnection = "" $objRecordSet = "" Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc but if i query 2 fields at the same time like and setting $objRecordSet.Fields(test).value i am getting errors $objRecordSet.Open ("Select CustomerID,CustFName as Test FROM "& $s_Tablename , $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText) $objRecordSet.Fields(test).value any help will be appreciated Thanks. Edited May 20, 2011 by Ace08 Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
ChrisL Posted May 20, 2011 Share Posted May 20, 2011 There is some SQL stuff in my signature, there is a _Jet_Connect function inside _SQL.au3 see how you get on with it. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Juvigy Posted May 20, 2011 Share Posted May 20, 2011 try this: $objRecordSet.Open ("Select * FROM"& $s_Tablename & "Order by 1 Asc" , $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText) Link to comment Share on other sites More sharing options...
Ace08 Posted May 20, 2011 Author Share Posted May 20, 2011 (edited) @ChrisL Thanks will look into this in the morning @Juvigy i've tried your code and i'm still getting errors i can only query 1 row at a time Edited May 23, 2011 by Ace08 Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now