Mackaaij Posted March 27, 2007 Posted March 27, 2007 Hello, I'm trying to create a System DSN with AutoIt. This works for Microsoft Excel but I need it for Visual FoxPro. I can't get the latter to function. After a few of those hours I decided to call in the real experts ;-) The main function is called GetAll() and can be found at the bottom of the script attached to this topic. This function states: ;This line does work ConfigDS($CfgOptions[0][0],$CfgOptions[0][1]) ;Create Excel Datasource ;I'd like the line below to work ConfigDS($CfgOptions[4][0],$CfgOptions[4][1]) ;Create FoxPro Datasource What I figured out is: * The DSN is created if all the parameters but the DSN name are passed * So there must be something wrong with the separator * The following separators won't work either ; | chr(0) * chr(0) as a separator is not possible since the string is then terminated The following command works in a command line box: odbcconf /a {configsysdsn "Microsoft Visual FoxPro Driver" "DSN=TestMyDataSource|Description=Test;SourceDB=D:\DATABASE\database.dbc|SourceType=DBC|Exclusive=Yes|BackgroundFetch=Yes|Collate=Machine|Null=No|Deleted=Y es"} Whether the DSN is created can be checked on the System-DSN tab after running odbcad32. P.S.: The script in general is from another forum topic somewhere around here. I added the Visual FoxPro part myself.AutoIt_create_DSN.au3
ptrex Posted March 28, 2007 Posted March 28, 2007 @thefounderThe way to do it is use a DSN Less connection to VFPDSN Less ConnectionEnjoy !!ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Mackaaij Posted March 28, 2007 Author Posted March 28, 2007 @ptrex Thanks for the reply. I cannot get it working with only the info you provied. I created a new script consisting of two commands only. It returns: Error: The requested action with this object has failed. This is the script: $oConn = ObjCreate ("ADODB.Connection") $oConn.Open "Driver={Microsoft Visual FoxPro Driver};" & _ "SourceType=DBC;" & _ "SourceDB=D:\database\database.dbc;" & _ "Exclusive=Yes" What I'm trying to do is check if the database can be opened exlusive. Then I might run a select on the database and that's about it. I cannot get the connection with Visual FoxPro working however (weird is that the Excel connection does work). I'd also like the script to run on a computer with as little installed as possible. ADODB requires more than ODBC, isn't this a fact?
ptrex Posted March 28, 2007 Posted March 28, 2007 @thefounder I'd also like the script to run on a computer with as little installed as possible. ADODB requires more than ODBC, isn't this a fact? Accrding to my knowledge the ADODB is available on every windows by default. So nothing to install. What the error concernes, I can"t test becauise I don't have a VFP around. Use this COM error check to debut the error. ; begin of the script $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; your code here ; end of the script Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM 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 regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Mackaaij Posted March 28, 2007 Author Posted March 28, 2007 @ptrexAccrding to my knowledge the ADODB is available on every windows by default.So nothing to install.=> OK, thanks for the info.What the error concernes, I can"t test becauise I don't have a VFP around.=> a MSI can be found here: http://msdn2.microsoft.com/en-us/vfoxpro/bb190233.aspxThe COM returned an error indeed: 80020009. Uploaded as a screenshot. I Googled this errorcode but it did not help me get any further.
odaylton Posted February 10, 2013 Posted February 10, 2013 Hello, I'm trying to create a System DSN with AutoIt. This works for Microsoft Excel but I need it for Visual FoxPro. I can't get the latter to function. After a few of those hours I decided to call in the real experts ;-) The main function is called GetAll() and can be found at the bottom of the script attached to this topic. This function states: ;This line does work ConfigDS($CfgOptions[0][0],$CfgOptions[0][1]) ;Create Excel Datasource ;I'd like the line below to work ConfigDS($CfgOptions[4][0],$CfgOptions[4][1]) ;Create FoxPro Datasource What I figured out is: * The DSN is created if all the parameters but the DSN name are passed * So there must be something wrong with the separator * The following separators won't work either ; | chr(0) * chr(0) as a separator is not possible since the string is then terminated The following command works in a command line box: odbcconf /a {configsysdsn "Microsoft Visual FoxPro Driver" "DSN=TestMyDataSource|Description=Test;SourceDB=D:DATABASEdatabase.dbc|SourceType=DBC|Exclusive=Yes|BackgroundFetch=Yes|Collate=Machine|Null=No|Deleted=Y es"} Whether the DSN is created can be checked on the System-DSN tab after running odbcad32. P.S.: The script in general is from another forum topic somewhere around here. I added the Visual FoxPro part myself. translated by google (sorry for mistakes) (PTBR) I know it is another matter but who knows with their esperiencias would possibly help me. I have a program in foxpro done by others and can control it perfectly but I would make sure the current focus. I can get the handle of the current form but do not know where I'm joined field. Control only send () and sleep (500) between ({TAB}) sent for each registration but I would be sure to identify which field I am really alert by current focus. x, y coordinate of the field or Handle field name or if there
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