Jump to content

Search the Community

Showing results for tags 'sql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

  1. I want to present BETA Version of my ADO.au3 UDF. This is modifed version of _sql.au3 UDF. For that I want to thanks : ; Chris Lambert, eltorro, Elias Assad Neto, CarlH This is first public release , and still is as BETA DOWNLOAD LINK (in download section): Have fun, mLipok EDIT: 2016-06-03 Below some interesting topics about databases: EDIT 2016/07/04: For more info about ADO look here: https://www.autoitscript.com/wiki/ADO FOR EXAMPLE DATABASE use AdventureWorksDW2016_EXT.bak from: https://github.com/microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2016_EXT.bak I will relay on this database in my examples. Here is link to post which shows how "ODBC Data Source Administrator" looks like.
  2. I am encountering a perplexing issue while running a script, and I would appreciate your insights and assistance in resolving it. Here's a brief description of the problem: When I execute the script within the AutoIt environment, it runs smoothly without any errors or problems. However, when I compile the script into an executable and attempt to run it, an error occurs stating, "Variable used without being declared." I have made diligent efforts to identify the undeclared variable, but unfortunately, I have been unsuccessful in locating it. I have reviewed EzMySqll.au3 UDF made by @Yoriz thoroughly, and declared all undeclared variables now they all appear to be appropriately declared before usage. Global $str_db_host, $str_db_user, $str_db_password, $str_database Func data_computers_insert() Local $serialNumber Local $computerName Local $submissionDate Local $sqlQuery ; Start the MySQL connection _EzMySql_Startup() ; Open the connection to the database _EzMySql_Open($str_db_host, $str_db_user, $str_db_password, $str_database, "3306") If @error Then MsgBox(16, "Error", "Failed to open the MySQL connection.") Return EndIf ; Set the values for the computer $serialNumber = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemProductName") If @error Then MsgBox(16, "Error", "Failed to read the serial number from the registry.") _EzMySql_Close() _EzMySql_ShutDown() Return EndIf $computerName = @ComputerName $submissionDate = @YEAR & "-" & @MON & "-" & @MDAY ; Build the SQL query $sqlQuery = "INSERT INTO Computers (SerialNumber, ComputerName, SubmissionDate) VALUES ('" & $serialNumber & "', '" & $computerName & "', '" & $submissionDate & "')" ; Display the SQL query in the console ConsoleWrite("SQL Query: " & $sqlQuery & @CRLF) ; Execute the query _EzMySql_Exec($sqlQuery) If @error Then MsgBox(16, "Error", "Failed to execute the SQL query.") _EzMySql_Close() _EzMySql_ShutDown() Return EndIf _EzMySql_Close() _EzMySql_ShutDown() EndFunc I run this script using mentioned UDF. But I keep getting error when my program is compiled. After error msgbox there is an empty file created called libmySQL_x64.dll, and its only created there when I get an error.
  3. Other than different methodologies, are there any differences between the two? Does one work out to be faster or more reliable than the other when deployed at scale? I'm trying out both UDFs, was curious which method is preferred by the community.
  4. Hello Guys, I am running the Ado example script, if I run this line, it runs without errors : Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & $sUser & ';PWD=' & $sPassword & ';' But when I try the windows auth one , it failed everytime : Func _Example_MSSQL_WindowsAuthorization() Local $sDatabase = 'AdventureWorks2016' Local $sServer = 'SQLSRV' _Example_5_MSSQL_WinAuth($sServer, $sDatabase, "Select * from Person.Address") EndFunc here is the error : ADO.au3 v.2.1.16 BETA (1204) : ==> COM Error intercepted ! $oADO_Error.description is: Provider cannot be found. It may not be properly installed. $oADO_Error.windescription: Exception occurred. $oADO_Error.number is: 80020009 $oADO_Error.lastdllerror is: 0 $oADO_Error.scriptline is: 1204 $oADO_Error.source is: ADODB.Connection $oADO_Error.helpfile is: C:\Windows\HELP\ADO270.CHM $oADO_Error.helpcontext is: 1240655 By the way, I have 64x windows server 2016 with SQL Server , I already installed the odbc my sql connector, any thought on this will be greatly appreciate it.
  5. Version 2.1.19 BETA

    11,872 downloads

    I want to present BETA Version of my ADO.au3 UDF. Support topic is here: http://www.autoitscript.com/forum/index.php?showtopic=180850 This UDF is modifed version of _sql.au3 UDF. For that I want to thanks : ; Chris Lambert, eltorro, Elias Assad Neto, CarlH
  6. Hi everyone, I am trying to make a script that runs a query and show it to me to see if everything is right and then decide if I finish it or not so I made a little script as below : #include <ADO.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> _ADO_EVENTS_SetUp(True) _ADO_ComErrorHandler_UserFunction(_ADO_COMErrorHandler) Local $sDriver = 'SQL Server' Local $sDatabase = 'DataBase' ; change this string to YourDatabaseName Local $sServer = 'Localhost' ; change this string to YourServerLocation Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & ';PWD=' & ';' ;~ Global $Query = _ ;~ "BEGIN TRAN" & @CRLF & _ ;~ "UPDATE Table" & @CRLF & _ ;~ "SET HOUR = 4" & @CRLF & _ ;~ "WHERE CUST = 'TEST'" & @CRLF & _ ;~ "SELECT * FROM Table" & @CRLF & _ ;~ "WHERE CUST = 'TEST'" & @CRLF & _ ;~ "ROLLBACK TRAN" Global $Query = _ "BEGIN TRAN" & @CRLF & _ "SELECT * FROM Table" & @CRLF & _ "WHERE CUST = 'TEST'" & @CRLF & _ "ROLLBACK TRAN" _Query_Display($sConnectionString, $Query) Func _Query_Display($sConnectionString, $sQUERY) ; Create connection object Local $oConnection = _ADO_Connection_Create() ; Open connection with $sConnectionString _ADO_Connection_OpenConString($oConnection, $sConnectionString) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) ; Executing some query directly to Array of Arrays (instead to $oRecordset) Local $aRecordset = _ADO_Execute($oConnection, $sQUERY, True) ; Clean Up _ADO_Connection_Close($oConnection) $oConnection = Null ; Display Array Content with column names as headers _ADO_Recordset_Display($aRecordset, 'Query Result') EndFunc ;==> _Query_Display When I ran this script it works great, but when I run the query below : Global $Query = _ "BEGIN TRAN" & @CRLF & _ "UPDATE Table" & @CRLF & _ "SET HOUR = 4" & @CRLF & _ "WHERE CUST = 'TEST'" & @CRLF & _ "SELECT * FROM Table" & @CRLF & _ "WHERE CUST = 'TEST'" & @CRLF & _ "ROLLBACK TRAN" It doesn't show anything, when I take those begin and rollback it does what it should but still not showing me anything at all, is there a way around it that you know of? Thank you.
  7. Hello, I would like a query to know if an entry exists Thank you in advance. $sQuery = "SELECT Alger FROM garage where auto='BL1879'" $result1 = $result.Fields("Alger").Value if $result1="" Then MsgBox(0, "ERROR", "BAD not exist") Else MsgBox(0, "Success!", "OK exist") EndIf Exit
  8. $sQueryUpdateTime = "select intUpdateTime from tblStudies " . $where . " ORDER BY intUpdateTime DESC limit 1"; $rs = mysqli_query($conn, $sQueryUpdateTime); $row = mysqli_fetch_assoc($rs); the above used to take 300+ ms. to query. Then I set it as index and takes 30 ms. Cool. $sQuery = "select * from tblStudies " . $where . " ORDER BY StudyDate DESC limit $offset,$rows"; // takes 30 ms. on the indexed int $sQuery = "select * from tblStudies " . $where . " ORDER BY StudyDate DESC , PatientName ASC limit $offset,$rows"; // takes 300 ms. due to "PatientName" been a text field, even as I did index it So my observation is that "PatientName" takes a long time to sort, even tho "$rows = 20". Sorting text in 20 rows should be fast. ..tho, I find that any 2nd argument in the ORDER BY is just slow. Is there a way to query this in a way to have a faster result back ? Thanks PS: added ADD INDEX `StudyDate_2` (`StudyDate`, `PatientBirthDate`) USING BTREE; and searched by those two with not much speed change ( StudyDate and PatientBirthDate are integer ).
  9. Hello, I was looking for a way to use the CLR functions to check a SQL 2016 database state, but I've been unable to find an example that I can get to work. Any help would be appreciated. Here's what I have, which always errors when I try to set the connection string and I'm not sure why. Thanks! #include ".\Includes\CLR.au3" #include ".\Includes\CLR Constants.au3" JustATest() Func JustATest() Local $oAssembly = _CLR_LoadLibrary("System.Data") ConsoleWrite("$oAssembly: " & IsObj($oAssembly) & @CRLF) Local $oSQLConn = _CLR_CreateObject($oAssembly, "System.Data.SqlClient.SqlConnection") ConsoleWrite("$oSQLConn: " & IsObj($oSQLConn) & @CRLF) $oSQLConn.ConnectionString = "Server=serverip;Database=dbname;UID=user;PWD=aaaa;" $oSQLConn.Open EndFunc Edit: I am using ptrex's CLR UDF from here:
  10. Good morning, I am trying to figure out if it is possible to check if these invoice lines exist or not. Here are the table and column name: INVOICELINE.INVOICELINENUM (a required field if created) Here is a picture of what I am talking about. (Do not worry about security. the picture is from a demo test site so all information is fake) is there any way to check if these fields exist or not? (they do not exist unless the user clicks on "New Row") Example: line 11 does not exist right now. How would I go about to see if it did or not? This is what I have so far: SELECT DISTINCT iv.invoicenum, iv.description FROM invoice AS iv JOIN invoiceline AS ivl ON iv.invoicenum = ivl.invoicenum AND iv.siteid = ivl.siteid /* = 'nothing' and yet somehow not null? */ WHERE iv.invoicenum NOT IN (SELECT invoicelinenum FROM invoiceline WHERE invoicelinenum IS NOT NULL) I get 0 results where I should get more than 0.
  11. Hey Guys, I've been using AutoIT for about 3 years now, lurking the forums, scouring documentation, and creating things relevant to my job function. I work entry level IT and utilizing AutoIT has earned me much respect in the workplace. I made my first application on the level of sharing with the community that has no relevance to my company other than the data that is used with it. Our tech's were using development software to make simple pre-written queries. I was made aware of the process in order to assist in automating it. We found that the software they were using was being sunset in our environment so they'd need a replacement; and upon me realizing that they only needed a simple query tool, decided to 'homegrow' a simple app and save some hefty licensing fees. I built in some versatility to the SQL database you can connect to but it is only tested working with a Sybase 15 system (note the example connection string). I'd love to hear some suggestions and critique. I'm sure there are some editing functionalities that I could implement into the query edit box that I haven't bothered looking at. (other than CTRA+A to select all) Thanks guys! #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <GuiListView.au3> #include <File.au3> #include <Crypt.au3> #include <Date.au3> $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Local $unique = "SQL-Query-Tool" ;TO ALLOW ONLY ONE INSTANCE OF THE TOOL If WinExists($unique) Then MsgBox(0,'Duplicate Process', 'This script is already running....' & @CRLF & "If the window is not visible, terminate the process from Task Manager" & @CRLF & 'This instance will terminate after clicking OK') Exit EndIf AutoItWinSetTitle($unique) Local $fResized = False, $GUIs, $temp, $Qlist[0][3], $x, $selQ[2], $guics[4] Local $conName, $conStr, $conPW, $selC, $selConn, $sqlErr Local $fh Local $readme = "You may delete this entry if desired once other ." & @CRLF & _ "Although it is prefaced with 'zz' for sorting" & @CRLF & _ @CRLF & _ "-Select a Query from the drop-down" & @CRLF & _ "-Note: changing selection will not lose" & @CRLF & _ " changes made during this session" & @CRLF & _ "-Click Run Query to produce results" & @CRLF & _ @CRLF & _ "-Select from 'Query Options' to create new," & @CRLF & _ " edit name, save, and delete queries" & @CRLF & _ @CRLF & _ "-Click 'Connection Settings' to change" & @CRLF & _ " server settings" $conName = IniReadSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Name") If @error = 1 Then DirCreate(@AppDataDir & "\SQL-Query-Tool\") IniWrite(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Name", "1", "Connection_Name_Placeholder") IniWrite(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-String", "1", "Connection_String_Placeholder") IniWrite(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Password", "1", "Connection_Password_Placeholder") EndIf $selConn = IniRead(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Selected", "Number", "Placeholder") If $selConn = "Placeholder" Then DirCreate(@AppDataDir & "\SQL-Query-Tool\") IniWrite(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Selected", "Number", "1") $selConn = 1 EndIf $temp = _FileListToArray(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\") If @error = 1 Or @error = 4 Then DirCreate(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\") FileWrite(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\zz_Readme.txt", $readme) $temp = _FileListToArray(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\") EndIf QueryLoad(False) $selQ[0] = $Qlist[1][0] Local $GUI = GUICreate("Simple SQL Query Tool", 260, 320, -1, -1, BitOR($WS_SIZEBOX,$WS_MINIMIZEBOX));, @DesktopWidth-275, @DesktopHeight-500) GUIRegisterMsg($WM_SIZE, 'MY_WM_SIZE') Local $querysel = GUICtrlCreateCombo("", 5, 5, 155, 25, $CBS_DROPDOWNLIST) GUICtrlSetData($querysel, $Qlist[0][1], $Qlist[1][0]) GUICtrlSetResizing(-1, 552) Local $queryopt = GUICtrlCreateCombo("Query Options", 165, 5, 90, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($queryopt, "Save to File|New|Edit Name|Delete|Open Query Folder") GUICtrlSetResizing(-1, 552) Local $tab = GUICtrlCreateTab(5, 35, 235, 200) $qtab = GUICtrlCreateTabItem(" Query ") Local $query = GuiCtrlCreateEdit("", 10, 60, 240, 170) GUICtrlSetFont(-1, 9, 0, 0, "Lucida Console") GUICtrlSetData($query, $Qlist[1][1]) $rtab = GUICtrlCreateTabItem(" Results ") Local $result = GuiCtrlCreateEdit("", 10, 80, 240, 150) GUICtrlSetFont(-1, 9, 0, 0, "Lucida Console") Local $status = GUICtrlCreateLabel("Last Ran: None", 15, 62, 500) GUICtrlSetResizing(-1, 802) GUICtrlCreateTabItem("") Local $run = GUICtrlCreateButton("Run Query", 5, 270, 130, 25) GUICtrlSetResizing(-1, 584) Local $settings = GUICtrlCreateButton("Connection Settings", 140, 270, 115, 25) GUICtrlSetResizing(-1, 584) Local $consel = GUICtrlCreateCombo("", 5, 5, 390, 25, $CBS_DROPDOWNLIST) GUICtrlSetResizing(-1, 802) Local $newc = GUICtrlCreateButton("New", 400, 5, 40, 20) GUICtrlSetResizing(-1, 802) Local $edic = GUICtrlCreateButton("Edit", 445, 5, 40, 20) GUICtrlSetResizing(-1, 802) Local $delc = GUICtrlCreateButton("Delete", 490, 5, 40, 20) GUICtrlSetResizing(-1, 802) Local $test = GUICtrlCreateButton("Test Connection", 540, 5, 95, 20) GUICtrlSetResizing(-1, 802) Local $return = GUICtrlCreateButton("Return to Query", 640, 5, 95, 20) GUICtrlSetResizing(-1, 802) Local $divider = GUICtrlCreateLabel("",-5,30,760,3,BitOR($SS_SUNKEN,$WS_BORDER)) GUICtrlSetResizing(-1, 802) Local $cnamel = GUICtrlCreateLabel("Connection Name:", 15, 45) GUICtrlSetResizing(-1, 802) Local $cname = GUICtrlCreateInput("", 110, 41, 200, 20) GUICtrlSetResizing(-1, 802) Local $cstringl = GUICtrlCreateLabel(" Connection String" & @CRLF & _ "Replace your password with *PW*. For example:" & @CRLF & _ "Provider=ASEOLEDB;User ID=-USERID-;Password=*PW*;Data Source=-SERVER-:-PORT-;Initial Catalog=-DatabaseName-" & @CRLF & _ "If you need assistance with your specific connection string try using: https://www.connectionstrings.com/", 5, 70, 740, 60) GUICtrlSetResizing(-1, 802) Local $cstring = GUICtrlCreateInput("", 10, 125, 725, 20) GUICtrlSetResizing(-1, 802) Local $pwl = GUICtrlCreateLabel("Password:", 10, 165) GUICtrlSetResizing(-1, 802) Local $pw = GUICtrlCreateInput("", 65, 161, 340, 20, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) GUICtrlSetResizing(-1, 802) Local $savc = GUICtrlCreateButton("Save", 480, 161, 100, 20) GUICtrlSetResizing(-1, 802) Local $canc = GUICtrlCreateButton("Cancel", 600, 161, 100, 20) GUICtrlSetResizing(-1, 802) Guimod("SETTINGS", $GUI_HIDE+1) GuiMod('SETTINGS-ENTRY', $GUI_DISABLE) $selC = $selConn GuiMod('RELOAD-CON') Local $hSelAll = GUICtrlCreateDummy() Dim $AccelKeys[1][2] = [["^a", $hSelAll]] GUISetAccelerators($AccelKeys, $GUI) GUISetState(@SW_SHOW) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg ;Checks if a button has been pressed Case $querysel $selQ[1] = GUICtrlRead($querysel) If $selQ[0] <> $selQ[1] Then QuerySelect() GUICtrlSetState($qtab, $GUI_SHOW) Case $queryopt Switch GUICtrlRead($queryopt) Case "Save to File" $fh = FileOpen(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\" & GuiCtrlRead($querysel) & ".txt", 2) FileWrite($fh, GuiCtrlRead($query)) $Qlist[_ArraySearch($Qlist, GuiCtrlRead($querysel), 0, 0, 0, 0, 1, 0)][1] = GuiCtrlRead($query) $Qlist[_ArraySearch($Qlist, GuiCtrlRead($querysel), 0, 0, 0, 0, 1, 0)][2] = False GUICtrlSetData($qtab, " Query ") Case "New" $temp = InputBox("New Query Name","Enter a name for your new query." & @CRLF & "Please be aware only letters, numbers, underscores, and spaces are allowed." & @CRLF & "Symbols will be removed.", "", "", Default, Default, Default, Default, 0, $GUI) $temp = StringRegExpReplace($temp, "[^A-Za-z0-9 _]", "") If $temp <> "" And _ArraySearch($Qlist, $temp, 0, 0, 0, 0, 1, 0) = -1 Then FileWriteLine(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\" & $temp & ".txt", "--First Line Placeholder") QueryLoad() GUICtrlSetData($querysel, "") GUICtrlSetData($querysel, $QList[0][1], $temp) $selQ[1] = GUICtrlRead($querysel) If $selQ[0] <> $selQ[1] Then QuerySelect() Else MsgBox(0,'Invalid Input','Invalid name entered. (Symbols and Duplicate Names are not allowed)', 0, $GUI) EndIf Case "Edit Name" $temp = InputBox("Edit Query name","Enter a new name for your query." & @CRLF & "Please be aware only letters, numbers, underscores, and spaces are allowed." & @CRLF & "Symbols will be removed.", GuiCtrlRead($querysel)) $temp = StringRegExpReplace($temp, "[^A-Za-z0-9 _]", "") If $temp <> "" And _ArraySearch($Qlist, $temp, 0, 0, 0, 0, 1, 0) = -1 Then FileMove(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\" & GuiCtrlRead($querysel) & ".txt", @AppDataDir & "\SQL-Query-Tool\Saved-Queries\" & $temp & ".txt") $selQ[0] = $temp QueryLoad() GUICtrlSetData($querysel, "") GUICtrlSetData($querysel, $QList[0][1], $temp) $selQ[1] = GUICtrlRead($querysel) If $selQ[0] <> $selQ[1] Then QuerySelect() Else MsgBox(0,'Invalid Input','Invalid name entered. (Symbols and Duplicate Names are not allowed)', 0, $GUI) EndIf Case "Delete" If UBound($Qlist) = 2 Then MsgBox(0,'Deletion Error','You may not delete the only saved query', 0, $GUI) Else If MsgBox(4, 'Confirm Deletion', "Are you sure you want to delete the query named: " & @CRLF & GUICtrlRead($querysel), 0, $GUI) = 6 Then FileDelete(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\" & GuiCtrlRead($querysel) & ".txt") QueryLoad() GUICtrlSetData($querysel, "") GUICtrlSetData($querysel, $QList[0][1], $Qlist[1][0]) $selQ[1] = GUICtrlRead($querysel) $selQ[0] = $selQ[1] GUICtrlSetData($query, $Qlist[1][1]) EndIf EndIf Case "Open Query Folder" ShellExecute(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\") EndSwitch GUICtrlSetData($queryopt, 'Query Options', 'Query Options') Case $run GuiMod("RUNNING", $GUI_DISABLE) ToolTip("Executing SQL query, please wait...") $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Mode = 16 ; shared $sqlCon.CursorLocation = 3 ; client side cursor Local $connString = StringReplace(GuiCtrlRead($cstring), "*PW*", GuiCtrlRead($pw)) $sqlCon.Open($connString) If @error Then MsgBox(0, "Fail", "Failed to connect to the database") Else $sqlCon.CommandTimeout = 60 GUICtrlSetData($result, ProcessQuery(GuiCtrlRead($query))) GUICtrlSetState($rtab , $GUI_SHOW) GuiCtrlSetData($status, "Last Ran: " & GuiCtrlRead($querysel) & " - " & StringRight(_NowCalc(), 8)) EndIf ToolTip("") GuiMod("RUNNING", $GUI_ENABLE) Case $settings ToolTip("Loading...") $selC = $selConn GuiMod('MAIN', $GUI_HIDE) GuiMod('RELOAD-CON') GuiMod('SETTINGS', $GUI_SHOW) ToolTip("") Case $consel If GUICtrlRead($consel) <> $selC Then $selC = _ArraySearch($conName, GUICtrlRead($consel), 0, 0, 0, 0, 1, 1) GUICtrlSetData($cname, $conName[$selC][1]) GUICtrlSetData($cString, $conStr[$selC][1]) GUICtrlSetData($pw, StringEncrypt(False, $conPW[$selC][1])) $selC = GUICtrlRead($consel) EndIf Case $newc GuiMod('SETTINGS-SELECT', $GUI_DISABLE) GuiMod('SETTINGS-ENTRY', $GUI_ENABLE) GuiCtrlSetData($consel, '*New-Connection-Entry*', '*New-Connection-Entry*') GuiCtrlSetData($cname, '') GuiCtrlSetData($cString, '') GuiCtrlSetData($pw, '') $selC = -1 Case $edic GuiMod('SETTINGS-SELECT', $GUI_DISABLE) GuiMod('SETTINGS-ENTRY', $GUI_ENABLE) $selC = GUICtrlRead($consel) _ArrayDisplay($conName, "2") $selC = _ArraySearch($conName, $selC, 0, 0, 0, 0, 1, 1) GuiCtrlSetData($cname, $conName[$selC][1]) $conName[$selC][1] &= "*" GuiCtrlSetData($cString, $conStr[$selC][1]) GuiCtrlSetData($pw, StringEncrypt(False, $conPW[$selC][1])) Case $delc If UBound($conName) = 2 Then MsgBox(0,'Error','You can not delete the only connection setting.', 0, $GUI) Else $selC = GuiCtrlRead($consel) If MsgBox(4, 'Confirm Deletion', 'Are you sure you want to delete the connection: ' & $selC, 0, $GUI) = 6 Then ToolTip('Loading...') $selC = _ArraySearch($conName, $selC, 0, 0, 0, 0, 1, 1) $conName[$selC][1] = '*!*BLANK*!*' $conStr[$selC][1] = '*!*BLANK*!*' $conPW[$selC][1] = '*!*BLANK*!*' IniWriteSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Name", $conName) IniWriteSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-String", $conStr) IniWriteSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Password", $conPW) GuiMod('RELOAD-CON') ToolTip('') EndIf EndIf Case $savc If GuiCtrlRead($cname) = "" Or _ArraySearch($conName, GuiCtrlRead($cname), 0, 0, 0, 0, 1, 1) > -1 Then MsgBox(0,'Invalid Input',"You can't have a blank connection name or two connections with the same name", 0, $GUI) Else ToolTip("Loading...") If $selC = -1 Then For $i = 1 To UBound($conName)-1 If $conName[$i][1] = '*!*BLANK*!*' Then $selC = $i $conName[$i][1] = GuiCtrlRead($cname) $conStr[$i][1] = GuiCtrlRead($cstring) $conPW[$i][1] = StringEncrypt(True, GuiCtrlRead($pw)) ExitLoop ElseIf $i = UBound($conName)-1 Then $selC = UBound($conName) _ArrayAdd($conName, UBound($conName) & "|" & GuiCtrlRead($cname)) _ArrayAdd($conStr, UBound($conStr) & "|" & GuiCtrlRead($cstring)) _ArrayAdd($conPW, UBound($conPW) & "|" & StringEncrypt(True, GuiCtrlRead($pw))) EndIf Next Else $conName[$selC][1] = GuiCtrlRead($cname) $conStr[$selC][1] = GuiCtrlRead($cstring) $conPW[$selC][1] = StringEncrypt(True, GuiCtrlRead($pw)) EndIf IniWriteSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Name", $conName) IniWriteSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-String", $conStr) IniWriteSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Password", $conPW) GuiMod('SETTINGS-SELECT', $GUI_ENABLE) GuiMod('SETTINGS-ENTRY', $GUI_DISABLE) GuiMod('RELOAD-CON') ToolTip('') EndIf Case $canc ToolTip("Loading...") GuiMod('SETTINGS-SELECT', $GUI_ENABLE) GuiMod('SETTINGS-ENTRY', $GUI_DISABLE) GuiMod('RELOAD-CON') ToolTip('') Case $test $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Mode = 16 ; shared $sqlCon.CursorLocation = 3 ; client side cursor Local $connString = StringReplace(GuiCtrlRead($cstring), "*PW*", GuiCtrlRead($pw)) $sqlCon.Open($connString) If @error Then MsgBox(0, "Fail", "Failed to connect to the database") Else MsgBox(0, "Success", "Successfully connected to the database") EndIf Case $return $selConn = _ArraySearch($conName, $selC, 0, 0, 0, 0, 1, 1) IniWrite(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Selected", "Number", $selConn) GuiMod('SETTINGS', $GUI_HIDE) GuiMod('MAIN', $GUI_SHOW) Case $hSelAll _SelectAllTextInEdit() Case $GUI_EVENT_CLOSE Exit EndSwitch If $fResized Then GuiMod('RESIZE') $fResized = False EndIf If $guics[0] = True Then _Input_Check($cname) WEnd Func QuerySelect() Local $oldp = _ArraySearch($Qlist, $selQ[0], 0, 0, 0, 0, 1, 0) Local $old = GuiCtrlRead($query) If $Qlist[$oldp][1] <> $old Then $Qlist[$oldp][1] = $old $Qlist[$oldp][2] = True EndIf Local $newp = _ArraySearch($Qlist, $selQ[1], 0, 0, 0, 0, 1, 0) GUICtrlSetData($query, $Qlist[$newp][1]) $selQ[0] = $selQ[1] If $Qlist[$newp][2] = False Then GUICtrlSetData($qtab, " Query ") Else GUICtrlSetData($qtab, " Query (unsaved) ") EndIf EndFunc Func QueryLoad($reload = True) Local $qFiles = _FileListToArray(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\") Local $tQlist[UBound($qFiles)][3] Local $selT $tQlist[0][0] = $qFiles[0] $tQlist[0][1] = "" For $i = 1 To $tQlist[0][0] $tQlist[$i][0] = StringTrimRight($qFiles[$i], 4) If $reload Then $selT = _ArraySearch($Qlist, $tQlist[$i][0], 0, 0, 0, 0, 1, 0) If $selT > -1 Then $tQlist[$i][1] = $Qlist[$selT][1] $tQlist[$i][2] = $Qlist[$selT][2] Else $tQlist[$i][1] = FileRead(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\" & $qFiles[$i]) $tQlist[$i][2] = False EndIf Else $tQlist[$i][1] = FileRead(@AppDataDir & "\SQL-Query-Tool\Saved-Queries\" & $qFiles[$i]) $tQlist[$i][2] = False EndIf $tQlist[0][1] &= StringTrimRight($qFiles[$i], 4) If $i < $tQlist[0][0] Then $tQlist[0][1] &= "|" Next $Qlist = $tQlist EndFunc Func ProcessQuery($input) Local $resultO = $sqlCon.Execute($input) If Not @error Then Local $resultT = "" Local $recordE = 0 Local $resultA[2][0] Local $i, $z While $recordE = 0 and IsObj($resultO) Redim $resultA[2][0] For $oField In $resultO.Fields Redim $resultA[2][UBound($resultA, 2)+1] $resultA[1][UBound($resultA, 2)-1] = $oField.Name Next ReDim $resultA[UBound($resultA)+1][UBound($resultA, 2)] While Not $resultO.EOF ReDim $resultA[UBound($resultA)+1][UBound($resultA, 2)] $i = 0 For $oField in $resultO.Fields $resultA[UBound($resultA)-1][$i] = StringStripWS(StringStripWS($oField.Value, 1), 2) $i += 1 Next $resultO.MoveNext WEnd For $i = 0 To UBound($resultA, 2)-1 $z = 0 For $x = 1 To UBound($resultA)-1 If StringLen($resultA[$x][$i]) > $z Then $z = StringLen($resultA[$x][$i]) Next $resultA[0][$i] = $z Next For $i = 0 To UBound($resultA, 2)-1 $z = "" For $x = 1 To $resultA[0][$i] + 4 $z &= "-" Next $resultA[2][$i] = $z Next For $x = 1 To UBound($resultA)-1 For $i = 0 To UBound($resultA, 2)-1 $resultT &= $resultA[$x][$i] For $z = StringLen($resultA[$x][$i]) To $resultA[0][$i] + 4 $resultT &= " " Next Next $resultT &= @CRLF Next $resultT &= @CRLF & "Total Lines Returned: " & UBound($resultA)-3 & @CRLF $resultT &= "__________________________________________________________" & @CRLF & @CRLF & @CRLF $resultO = $resultO.NextRecordset $recordE = @error WEnd $resultO.Close Else Local $resultT = $sqlErr EndIf Return $resultT EndFunc Func GuiMod($action, $toggle = 0) Switch $action Case 'RESIZE' If ($GUIs[2] < 266 or $GUIs[3] < 306) And $guics[0] = False Then WinMove($GUI, '', $GUIs[0], $GUIs[1], 276, 336) GUICtrlSetPos($tab, 5, 35, $GUIs[2] - 25, $GUIs[3] - 106) GUICtrlSetPos($query, 10, 60, $GUIs[2] - 36, $GUIs[3] - 136) GUICtrlSetPos($result, 10, 80, $GUIs[2] - 36, $GUIs[3] - 156) GUICtrlSetPos($result, 10, 80) Case 'MAIN' GUICtrlSetState($querysel, $toggle) GUICtrlSetState($queryopt, $toggle) GUICtrlSetState($tab, $toggle) GUICtrlSetState($query, $toggle) GUICtrlSetState($result, $toggle) GUICtrlSetState($status, $toggle) GUICtrlSetState($run, $toggle) GUICtrlSetState($settings, $toggle) Case 'SETTINGS' If $toggle = $GUI_SHOW Then GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_SYSMENU)) $GUIs = WinGetPos($GUI) $guics[0] = True $guics[1] = $GUIs[2] $guics[2] = $GUIs[3] $guics[3] = $GUIs[0] WinMove($GUI, '', 25, $GUIs[1], 750, 221) ElseIf $toggle = $GUI_HIDE Then GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_SYSMENU, $WS_SIZEBOX)) $guics[0] = False WinMove($GUI, '', $guics[3], Default, $guics[1], $guics[2]) ElseIf $toggle = $GUI_HIDE+1 Then $toggle -= 1 EndIf GUICtrlSetState($consel, $toggle) GUICtrlSetState($newc, $toggle) GUICtrlSetState($edic, $toggle) GUICtrlSetState($delc, $toggle) GUICtrlSetState($test, $toggle) GUICtrlSetState($return, $toggle) GUICtrlSetState($divider, $toggle) GUICtrlSetState($cnamel, $toggle) GUICtrlSetState($cname, $toggle) GUICtrlSetState($cstringl, $toggle) GUICtrlSetState($cstring, $toggle) GUICtrlSetState($pwl, $toggle) GUICtrlSetState($pw, $toggle) GUICtrlSetState($savc, $toggle) GUICtrlSetState($canc, $toggle) Case 'SETTINGS-SELECT' GUICtrlSetState($consel, $toggle) GUICtrlSetState($newc, $toggle) GUICtrlSetState($edic, $toggle) GUICtrlSetState($delc, $toggle) GUICtrlSetState($test, $toggle) GUICtrlSetState($return, $toggle) Case 'SETTINGS-ENTRY' GUICtrlSetState($cnamel, $toggle) GUICtrlSetState($cname, $toggle) GUICtrlSetState($cstringl, $toggle) GUICtrlSetState($cstring, $toggle) GUICtrlSetState($pwl, $toggle) GUICtrlSetState($pw, $toggle) GUICtrlSetState($savc, $toggle) GUICtrlSetState($canc, $toggle) Case 'RUNNING' GUICtrlSetState($querysel, $toggle) GUICtrlSetState($queryopt, $toggle) GUICtrlSetState($query, $toggle) GUICtrlSetState($tab, $toggle) GUICtrlSetState($result, $toggle) GUICtrlSetState($run, $toggle) GUICtrlSetState($settings, $toggle) Case 'RELOAD-CON' $conName = IniReadSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Name") $conStr = IniReadSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-String") $conPW = IniReadSection(@AppDataDir & "\SQL-Query-Tool\settings.ini", "Connection-Password") Local $sC = $conName _ArraySort($sC, 0, 1, 0, 1) GUICtrlSetData($consel, "") If $conName[$selC][1] <> "*!*BLANK*!*" Then GuiCtrlSetData($cname, $conName[$selC][1]) GuiCtrlSetData($cString, $conStr[$selC][1]) GuiCtrlSetData($pw, StringEncrypt(False, $conPW[$selC][1])) $selC = $conName[$selC][1] Else For $i = 1 To UBound($sC)-1 If $sC[$i][1] <> '*!*BLANK*!*' Then GuiCtrlSetData($cname, $sC[$i][1]) GuiCtrlSetData($cString, $conStr[$sC[$i][0]][1]) GuiCtrlSetData($pw, StringEncrypt(False, $conPW[$sC[$i][0]][1])) $selC = $sC[$i][1] ExitLoop EndIf Next EndIf For $i = 1 To UBound($sC)-1 If $sC[$i][1] <> '*!*BLANK*!*' Then GUICtrlSetData($consel, $sC[$i][1], $selC) Next EndSwitch EndFunc Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam) $GUIs = WinGetPos($GUI) $fResized = True Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_SIZE Func StringEncrypt($bEncrypt, $sData, $sPassword = 'SQL') If $sData = "" Then Return '' _Crypt_Startup() ; Start the Crypt library. Local $sReturn = '' If $bEncrypt Then ; If the flag is set to True then encrypt, otherwise decrypt. $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4) Else $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4)) EndIf _Crypt_Shutdown() ; Shutdown the Crypt library. Return $sReturn EndFunc ;==>StringEncrypt Func _Input_Check($hInput) Local $sText = GUICtrlRead($hInput) If StringRegExp($sText, "[^A-Za-z0-9 _]") Then GUICtrlSetData($hInput, StringRegExpReplace($sText, "[^A-Za-z0-9 _]", "")) EndFunc Func _SelectAllTextInEdit();will make select all text in any focused edit Local $theHandle = _WinAPI_GetFocus() Local $TheClass = _WinAPI_GetClassName($theHandle) If $TheClass = 'Edit' Then _GUICtrlEdit_SetSel($theHandle, 0, -1) EndFunc Func MyErrFunc() $HexNumber=hex($oMyError.number,8) $sqlErr = "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
  12. Only early days at this point, but I have been pondering such a program for a while. As good as calibre is (thank you Kovid Goyal), which is a great and wonderful ebook suite of tools and a fair database, it does have its limitations. One of which, is how it deals with multiple libraries, another is the views you get. CalibBrowser will seek to address those. What CalibBrowser is not going to be, is an editor for existing calibre libraries. That will be left up to calibre, which is very much needed still, and covers many aspects I will never look at. Unlike calibre, which is quite a complex program, CalibBrowser also seeks to be simple. It is mainly a viewer, at this point, but will later be able to create its own libraries. However, it does not and will not export them to calibre, especially as calibre employs a far different method and structure to what CalibBrowser will employ. When CalibBrowser starts, it looks for calibre executables and the main Calibre Library. Whatever isn't found, you get prompted for with a browse option. A calibre library, is a set of ebook folders (Author\Ebooks) and a database file, always named metadata.db, and which causes an issue when it comes to multiple libraries, but makes life a bit easier when reconstructing any corrupted libraries. However, there are better ways to deal with that, as my program will show. The metadata.db file is an SQL database, so I am having a learning curve right now, as I have only ever dealt with an SQL database previously, codewise, when I created my INItoSQL program some time last year, as an exercise to prove a point. At the moment, things are pretty basic, and not everything works 100%. Here is a screenshot, to give an idea of it, but keep in mind, I intend to expand the current GUI for other stuff I will be adding. Older Screenshots Gawd, I just noticed the '3|7' in the Book Input field (original screenshot). I was using that during troubleshooting for the multiple images scrolling and forgot to disable it ... not that it impacts anything. When it comes to maths, I struggle a bit, especially when tired. Right scrolling was easy, with a continuous loop, was easy to implement. Left scrolling was significantly harder for my poor brain ... until I realized I needed to see them as Min and Max. As you can see the program is usable, and all the buttons, aside from the Program Information one, work. You can even load different calibre libraries, and even reload after making changes to one with calibre. The calibre program does not need to be running, even to view an ebook in the Calibre Reader. The combo selector for a library and the ADD button are only temporarily placed where they are, until I expand the GUI. My intention at this point, is to add another five thumbnail images, directly below existing. Currently they aren't clickable, but I may add that. Here is another screenshot, of what you see when you click the larger Cover image. If you want to have a play with the program as is, then you will need to also get the 'sqlite3.dll' file from some online source. When CalibBrowser starts successfully with the selected calibre library, it copies its metadata.db file to a sub-folder of the program called 'Backups'. It also creates a sub-folder in that, based on the library name, to house it. That copied file, is the one the program uses, though it does not even edit that, and file modification is checked every time the program starts with a particular library, or when you Reload or select a library. If the original source file has been modified, then the program copy is overwritten. The Reload Database button does nothing, if there is no change detected, and reports such. Place the required 'sqlite3.dll' file in the CalibBrowser root folder. Download includes source files (sqlite3.dll excepted). Also required of course, is an install of calibre, plus some ebooks in a created library - Calibre Library is the default when you first add ebooks to calibre. The Mobile Read Forums, is a great source for all things ebook, and calibre can be found there in the E-Book Software section. CalibBrowser.zip 1.34 MB - Upload 4 (previous downloads: 1 + 12 + 5 + 282) CalibBrowser (new).zip My apologies for the program being created in AutoIt v3.3.0.0. It is the first one I have done in a while, with an older AutoIt version. Basically my Win 7 Netbook, which has a current version of AutoIt, was busy and is always busy doing something, and not suitable for doing big projects for several reasons. My older but more powerful Win XP Laptop, has a better programming environment, better computer chair (most important for my knees etc), better external monitor (wider and newish), full size external keyboard & mouse, and a great suite of setup tools to assist me. I run several older versions of AutoIt already on my Laptop, but haven't yet determined what I need to adjust to add a current version of AutoIt to the mix. This also applies to my hugely beneficial Toolbar For Any program (one of those tools), which I constantly use with SciTE. At some point, when finished, I may update the program to the current AutoIt version ... especially as I believe I am now proficient enough to do so, having become quite familiar with it in the last year or so, making many programs with it. Enjoy!
  13. Hi Guys, Fine? I have this code and I use it to perform the query, however when I change the query to INSERT it is not working return error. #include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Example() Func Example()     Local $dbname = FileOpenDialog("Choose Access Database", @ScriptDir, "Access files (*.accdb)", 1)     If @error then Return SetError(@error, @extended, 0)     $adoCon = ObjCreate("ADODB.Connection")     $adoCon.Open("Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & $dbname & ";Uid=;Pwd=;")     $adoRs = ObjCreate("ADODB.Recordset")     GUICreate("listview items", 550, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)     Local $idListview = GUICtrlCreateListView("Codigo    |Nome         |Valor  ", 10, 10, 520, 150) ;,$LVS_SORTDESCENDING     $queryInsert = INSERT INTO TABLENAME VALUES (''aaaaa'', ''bbbbbb'', ''cccccc'')     Local $aResult     With $adoRs         .CursorType = 2         .LockType = 3         .Open($queryInsert, $adoCon)         If @error Then             ; deal with Probable SQL error             Return SetError(1)         EndIf         If Not .EOF Then $aResult = .GetRows()         .Close()     EndWith     $adoRs = 0     _ArrayDisplay($aResult, 'UBound($aResult)=' & UBound($aResult))     For $iRow_idx = 0 To UBound($aResult) - 1         GUICtrlCreateListViewItem($aResult[$iRow_idx][0], $idListview)     Next     $adoCon.Close     GUISetState()     ; Loop until the user exits.     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 ExitLoop ;~             Case $idButton ;~                 MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)             Case $idListview                 MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)         EndSwitch     WEnd EndFunc   ;==>Example ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError)     ; Do anything here.     ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _             @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _             @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _             @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _             @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _             @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _             @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _             @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _             @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _             @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc   ;==>_ErrFunc Help, Please!
  14. Hello guys! I am having some difficulty in achieving a very simple task here. I have gone through the forums and tried some examples and UDFs but I can't seem to work it out. I would really appreciate if someone could help me out. Problem: Currently, I am logging the required feedback from the script into a log file in a simple way ... get the info in the var >> write it in the file But now I am in need to perform some analysis and need some of the values to go into an MSSQL table in the attached format Also, I need to be able to use Integrated Security" or "Trusted_Connection set as true or use the logged in windows credentials to connect to the server/database any help will be much appreciated!!! Thanks!
  15. I have created this function for a database, but I can not make it work. I always have two error messages: "not an error" ... and the file created, in the script directory, does not contain anything. Global $sDBName = "Hen.db" Func DatabaseTable() Local $sConnDB _SQLite_Startup() If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!") Exit -1 EndIf $sConnDB = _SQLite_Open($sDBName) If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!") Exit -1 EndIf If Not _SQLite_Exec($sDBName, 'CREATE TABLE Animal ("Name", "Age");') = $SQLITE_OK Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg()) If Not _SQLite_Exec($sDBName, 'INSERT INTO Animale VALUES ("Charlie","5");') = $SQLITE_OK Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg()) _SQLite_Close($sConnDB) _SQLite_Shutdown() EndFunc
  16. ..let's say I store in a mysql column "[1,2,11,12,123]". How can I make s query to get all those rows that is 1, or is 12, etc ? I'm using mysqlnd 5.0.11-dev - 20120503 Any advise on what technique I should use is welcomed Thanks PS: ..I'm adding a comma to each end, as in [,1,2,11,12,123,] and will search with like %,12,% . Not pretty but I'm in a hurry and can't come up with a better solution =/
  17. Dear all, I already have a formula which will select doublicates, but sometimes there might be entries with additional information starting after "-", which I now want to trim away. Current formula is: Select DISTINCT a.title, a.oid, a.size, a.disk from DB a, DB b where (a.title like b.title and a.oid <> b.oid)" & $ActiveDisks_Filter & " AND (a.comment <> 'Delete' AND b.comment <> 'Delete') Order by a.title ASC, a.size DESC; testwise I want to add a simple solution like left, but afterwards I get an error but I do not know why. Select DISTINCT a.title, a.oid, a.size, a.disk from DB a, DB b where (left(a.title,15) like b.title and a.oid <> b.oid) Order by a.title ASC, a.size DESC; Error: near "(": syntax error: Finally I would like to insert intstr to search for "-" but currently I am not able to extend my current code =/ Thanks a lot for your help. EDIT: hey, I managed it, left was not working also it was somehow shown that the tool knowed the comment. I did it now with substr+instr (substr(a.title, 1, instr(a.title, ' - '))
  18. I have code that does a WMI SQL query to find all defined printers, and I want to parse the returned object in several places. However, after parsing it the first time, all other times fail to find any printer objects. Here is my test code: test() Func test() Local $oPrinters, $oPrinter, $err, $cnt, $oP, $query $query = "SELECT * FROM Win32_Printer" $oPrinters = doQuery($query) $err = @error LogMsg("+++: $err = " & $err & ", isObj($oPrinters) = " & IsObj($oPrinters)) If ($err == 0) Then LogMsg("FIRST LOOP") ; <=== FIRST LOOP $cnt = 0 $oP = $oPrinters LogMsg("+++: isObj($oP) = " & IsObj($oP)) For $oPrinter In $oP $cnt += 1 LogMsg("+++: isObj($oPrinter): " & IsObj($oPrinter) & ", $oPrinter.Name ==>" & $oPrinter.Name & "<==") Next LogMsg("+++: Found " & $cnt & " printers") LogMsg("SECOND LOOP") ; <== SECOND LOOP $cnt = 0 $oP = $oPrinters LogMsg("+++: isObj($oP) = " & IsObj($oP)) For $oPrinter In $oP $cnt += 1 LogMsg("+++: isObj($oPrinter): " & IsObj($oPrinter) & ", $oPrinter.Name ==>" & $oPrinter.Name & "<==") Next LogMsg("+++: Found " & $cnt & " printers") EndIf EndFunc ;==>test Func doQuery($sQuery, $lnum = @ScriptLineNumber) #forceref $lnum LogMsg("+++:" & $lnum & ": doQuery(" & '"' & $sQuery & '"' & ") entered") Local $oWMIService, $oResults, $errstr Local $wbemFlags = BitOR(0x20, 0x10) ; $wbemFlagReturnImmediately and wbemFlagForwardOnly $oWMIService = ObjGet("winmgmts:\\" & "localhost" & "\root\CIMV2") If (IsObj($oWMIService)) Then $oResults = $oWMIService.ExecQuery($sQuery, "WQL", $wbemFlags) If (IsObj($oResults)) Then LogMsg("+++: doQuery() returns @error = 0, Good: returning the object") Return (SetError(0, 0, $oResults)) ;;; Good: return the object Else $errstr = "" _ & "WMI Query failed." & @CRLF _ & "This is the query:" & @CRLF _ & " " & $sQuery LogMsg("+++: ====>" & $errstr & "<===") LogMsg("+++: doQuery() returns @error = 1") Return (SetError(1, 0, $errstr)) ; Error: Query faled EndIf Else $errstr = "" _ & "WMI Output" & @CRLF _ & "No WMI Objects Found for class: " & @CRLF _ & "Win32_PrinterDriver" & @CRLF _ & "using this query:" & @CRLF _ & " " & $sQuery LogMsg("+++: ====>" & $errstr & "<===") MsgBox(0, "ERROR", $errstr) ; Error: Cannot get $oWMIService object Exit (1) EndIf EndFunc ;==>doQuery Func LogMsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>LogMsg Parsing the returned $oPrinters object shows 5 printers: +++:15: FIRST LOOP +++:18: +++: isObj($oP) = 1 +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Microsoft XPS Document Writer<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Microsoft Office Document Image Writer<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Fax<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Canon MG7100 series Printer WS<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Canon MG6100 series Printer WS<== +++:24: +++: Found 5 printers Parsing it again, shows no printers: +++:26: SECOND LOOP +++:29: +++: isObj($oP) = 1 +++:35: +++: Found 0 printers
  19. Hello guys ! I'm stuck in something stupid (I guess), but since I've no clue on how to solve it, here I come I'm trying to collect the result of the query "select @@hostname" on MSSQL Server, but it doesn't work ... and I'm sure I'm connected to the database (I've successfully seen the database treeview). #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include<_sql.au3> #include<array.au3> Local $aData,$iRows,$iColumns ;Server ID and credentials for tCards Global $ServerAddressT = "10.200.88.1" Global $ServerUserNameT = "user" Global $ServerPasswordT = "password" Global $DatabaseNameT = "DataBASE" ;Connect to DB _SQL_RegisterErrorHandler();register the error handler to prevent hard crash on COM error $OADODB = _SQL_Startup() If $OADODB = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg()) If _sql_Connect(-1, $ServerAddressT, $DatabaseNameT, $ServerUserNameT, $ServerPasswordT) = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error 1", _SQL_GetErrMsg()) _SQL_Close() Exit Else If _SQL_Execute(-1,"select @@SERVERNAME") = $SQL_ERROR then Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg()) Else _ArrayDisplay(_SQL_GetTable(-1,"select @@SERVERNAME",$aData,$iRows,$iColumns)) ;~ $toto = _SQL_Execute(-1,"select @@SERVERNAME") ;~ _ArrayDisplay($toto) EndIf EndIf
  20. I have an Autoit-based client GUI that uses a single MS SQL Server database. I have no problem connecting to and executing queries against this database from my AutoIT code, with the below exception: One of the database's stored procedures I need to execute requires a parameter that is a table. I've set up the appropriate table_type on the database and everything works fine on the database itself when I execute the stored proc with a table variable for the parameter (no AutoIT involved). The problem is that I can't figure out how to pass a table parameter from AutoIT, assuming it's even possible. The code below shows the two methods I've tried, both methods return a RecordSet object that is at EOF. #include <Array.au3> Opt("MustDeclareVars", 0) $sDBSrv = "ITSQL01.domain.com" $sDBName = "INVDEV" $sADOName = "ADODB.Connection" $oSQLConn = ObjCreate($sADOName) $sConnStr = "Driver={SQL Server};Server=" & $sDBSrv & ";Database=" & $sDBName & ";Trusted_Connection=yes;" $oSQLConn.Open ($sConnStr) $rsoFacFriendly = $oSQLConn.Execute("SELECT TOP 5 FriendlyName FROM Facility") If Not $rsoFacFriendly.EOF Then $aFacFriendly = $rsoFacFriendly.GetRows() _ArrayDisplay($aFacFriendly) $rsoSPResults = $oSQLConn.Execute("EXEC spTableParameterPassTest " & $aFacFriendly) Select Case $rsoSPResults.EOF = False MsgBox(0, "sp exec1", "not end of file") $aSPResults = $rsoSPResults.GetRows() _ArrayDisplay($aSPResults) Case IsObj($rsoSPResults) = 0 MsgBox(0, "sp exec1", "rso isn't even an object") Case $rsoSPResults.EOF = True MsgBox(0, "sp exec1", "At end of file") Case Else MsgBox(0, "sp exec1", "Something else happened") EndSelect $rsoSPResults = 0 $rsoSPResults = $oSQLConn.Execute("EXEC spTableParameterPassTest " & $rsoFacFriendly) Select Case $rsoSPResults.EOF = False MsgBox(0, "sp exec2", "not end of file") $aSPResults = $rsoSPResults.GetRows() _ArrayDisplay($aSPResults) Case IsObj($rsoSPResults) = 0 MsgBox(0, "sp exec2", "rso isn't even an object") Case $rsoSPResults.EOF = True MsgBox(0, "sp exec2", "At end of file") Case Else MsgBox(0, "sp exec2", "Something else happened") EndSelect $rsoSPResults = 0 $rsoFacFriendly = 0 $oSQLConn.Close $oSQLConn = 0 Exit
  21. romaSQL This autoIt UDF is built on the concept of Laravel Query & doctrine. RomaSQL provides a new, comfortable and easy to use way for SQL-queries in autoIt. Most of the common SQL-queries are supported already and more are coming soon. All of your support is much appreciated. Connections For the connection the object ADODB is used. Therefore the connection string is based on ODBC. You can also use OLEDB connection strings or other database connections. In order for this to work your add-ons have to be installed in the function: __4ern_SQL_Connection. I’d be very glad if you shared your modifications with me. Currently supported connections - MySQL (odbc) - Microsoft SQL Server (odbc) - SQLite (odbc) - Microsoft Access (odbc) Command reference $SQL_connect; establishing connection $SQL_returnType; return a Array or Dictionary ('oDict') Object (Default = Array) $SQL_setDefaultTable; Default Tablename $SQL_setDefaultKey; Default Colmn Key (Default = id) $SQL_debug; if True, show SQL Statment in Console $SQL_get $SQL_update $SQL_delete $SQL_insertInto $SQL_take $SQL_limit $SQL_table $SQL_select $SQL_distinct $SQL_where $SQL_orWhere $SQL_whereBetween $SQL_whereNotBetween $SQL_whereIn $SQL_whereNotIn $SQL_whereNull $SQL_whereNotNull $SQL_having $SQL_orHaving $SQL_havingBetween $SQL_havingNotBetween $SQL_havingIn $SQL_havingNotIn $SQL_havingNull $SQL_havingNotNull $SQL_groupBy $SQL_orderBy Examples establishing connection ;-----/ ; SQLite Connection ;-----/ $SQL_setDatabase('sqlite') $SQL_connect('C:\project.db') ;-----/ ; Access Connection ; Database, User, Password ;-----/ $SQL_setDatabase('access') $SQL_connect('C:\project.mdb') ;or as Admin $SQL_connect('C:\project.mdb', '4ern', 'root') ;-----/ ; SQLServer Connection ; Database, User, Password, Server, Driver ;-----/ $SQL_setDatabase('sqlserver') $SQL_connect('myDB', '4ern', 'root', 'localhost') ;or with Driver $SQL_connect('myDB', '4ern', 'root', 'localhost', 'SQL Server') ;-----/ ; MySQL Connection ; Database, User, Password, Server, Driver ;-----/ $SQL_setDatabase('mysql') $SQL_connect('myDB', '4ern', 'root', 'localhost') ;or with Driver $SQL_connect('myDB', '4ern', 'root', 'localhost', 'MySQL ODBC 5.2 UNICODE Driver') simple SQL query $SQL_table('albums') $aRet = $SQL_get() if IsArray($aRet ) then _ArrayDisplay($aRet ) else ConsoleWrite('Keine Ergebnisse' & @LF) endif Select $SQL_table('albums') $SQL_select('id', 'Name', 'Artist', 'Song') ;or pass to an Array Local $aSelect = ['id', 'Name', 'Artist', 'Song'] $SQL_select($aSelect) $aRet = $SQL_get() if IsArray($aRet ) then _ArrayDisplay($aRet ) else ConsoleWrite('Keine Ergebnisse' & @LF) endif where $SQL_table('albums') $SQL_select('id', 'Name', 'Artist', 'Song', 'Votes') $SQL_where('Artist', 'adele') $SQL_where('Votes', '>=' ,'9') $SQL_orWhere('Artist', '=' ,'Rag'n'Bone Man') ;or pass to an 2dArray Local $aSelect = [['Artist','adele'],['Votes', '>=' ,'9']] $SQL_where($aSelect) $aRet = $SQL_get() if IsArray($aRet ) then _ArrayDisplay($aRet ) else ConsoleWrite('Keine Ergebnisse' & @LF) endif If you need more examples, then tell me exactly what you need. I hope you like my UDF and find some use for it. --- ->DONWLOAD romaSQL
  22. Hi, I want to click a link by the element ID through IEGetObjById. <!DOCTYPE html> <html> <body> <button type="button" id="Random-1-ID" onclick="alert('Hello world!')"></button> </body> </html> I intend to click the button with ID"Random-1-ID". But on every refresh the ID changes to next number like "Random-2-ID" "Random-3-ID" The code i which i wrote for this function is #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate("I:\Documents\1. Work\Automation\My codes\Collections\11. Clicking button by Value and ID\button.html") Local $oDiv = _IEGetObjById($oIE, "Random-1-ID") _IEAction($oDiv, "click") _IELoadWait($oIE) So can anyone help me to alter this code like it clicks for every ID in format "Random-%-ID"
  23. I hope my title is good enough. I'm using the ADO UDF and I have question regarding editing SQL records with this UDF. The owner of the UDF suggested an idea, but maybe there is another trix.
  24. DB1: CREATE TABLE [dbo].[Item]( [ItemID] [nchar](10) NOT NULL, [Money] [bigint] NOT NULL, CONSTRAINT [PK_Item] PRIMARY KEY CLUSTERED ( [ItemID] ASC ) ON [PRIMARY] ) ON [PRIMARY] GO CREATE TABLE [dbo].[Account]( [Index] [int] IDENTITY(1,1) NOT NULL, [AccountID] [nchar](10) NOT NULL, [AccountName] [int] NOT NULL, [ItemList] [int] NOT NULL, ) ON [PRIMARY] GO CREATE TABLE [dbo].[Money]( [AccountID] [nchar](10) NOT NULL, [Money] [bigint] NOT NULL, CONSTRAINT [PK_Money] PRIMARY KEY CLUSTERED ( [AccountID] ASC ) ON [PRIMARY] ) ON [PRIMARY] GO DB2: CREATE TABLE [dbo].[Item]( [ItemID] [nchar](10) NOT NULL, [Money] [bigint] NOT NULL, [ItemName] [bigint] NOT NULL, [MoneyType] [bigint] NOT NULL, CONSTRAINT [Item] PRIMARY KEY CLUSTERED ( [ItemID] ASC ) ON [PRIMARY] ) ON [PRIMARY] GO CREATE TABLE [dbo].[Account]( [Index] [int] IDENTITY(1,1) NOT NULL, [AccountID] [nchar](10) NOT NULL, [AccountName] [int] NOT NULL, [ItemList] [int] NOT NULL, ) ON [PRIMARY] GO CREATE TABLE [dbo].[Money]( [AccountID] [nchar](10) NOT NULL, [Money] [bigint] NOT NULL, [MoneyType] [bigint] NOT NULL, CONSTRAINT [Money] PRIMARY KEY CLUSTERED ( [AccountID] ASC ) ON [PRIMARY] ) ON [PRIMARY] GO Compare and merge database. alter table [Item] add [ItemName] bigint not null default(0) alter table [Item] add [MoneyType] bigint not null default(0) alter table [Money] add [MoneyType] bigint not null default(0) Please help automate code AutoIt to generation new code for large sql file. Thanks
  25. Hi guys, This post was originally going to be a question on how to fix this issue but as I ended up figuring it out I thought I'd post it here for others that have the same issue. So you've downloaded and extracted the latest version of the SQLite dll files etc into the same directory as your SQLite script but it's failing at _SQLite_Startup()? What you need to do, that I couldn't see anywhere in the documentation, to fix the issue is rename the dll files from (for example) "sqlite3_301500000.dll" to "sqlite3.dll" and "sqlite3_x64_301500000.dll" to "sqlite3_x64.dll". Fixed my issues instantly! Hope it can help others too. Cheers.
×
×
  • Create New...