Jump to content

Recommended Posts

  • Replies 385
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

here's the first release... only a few functions so far, any input would be appriciated Todo: _CreateTable() _CreateColumn() _DropCol() _DropTbl() _CountRecords() _CountTables() _GetTblNames() _GetCol

So much for homework lol... No includes, ready to compile and use wherever you like. Global Const $ES_PASSWORD = 32 Global Const $ES_AUTOVSCROLL = 64 Global Const $ES_AUTOHSCROLL = 128 $sDr

Try to use my ADO.au3 UDF - look in my signature.

Posted Images

That's what one gets when composing code right in the edit control and copy/paste things without taking time to check it worked. My bad.

; insert required #includes

Local $MYSQLUserName = "u_autoit"
Local $MYSQLPassword = "123"
Local $MYSQLDatabase = "autoit"
Local $MySQLServerName = "localhost"
Local $Literal = 'Khát Vọng'
Local $SQLQuery = _MySQLConnect($MYSQLUserName, $MYSQLPassword, $MYSQLDatabase, $MySQLServerName)
Local $data
Local $Result = _Query($SQLQuery,"SELECT '" & $Literal & "' as test;")
If @error Then
    MsgBox(0, "Error SQL", "Error when executing SQL")
Elseif IsObj($Result) Then
    With $Result
        While Not .EOF
            $data = .Fields("test").value
            .MoveNext
        WEnd
    EndWith
Else
    MsgBox(0, "SQL Error", "Something went wrong without error. Maybe no result ?")
EndIf
MsgBox(0, 'MySQL literal', $data)

MsgBox(0, 'AutoIt literal', $Literal)

My MySQL-fu is limited as I don't use this engine myself but this should work up to the point of displaying whether the ADO (= ODBC) driver works as expected.

MySQL gurus welcome to chime.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

@donnguyen:

AFAIK, mysql UDF use MySql ODBC Driver version 3.51, which basically does not support UTF-8 encoding. So, you may try two options:

1. Use Driver version 5.x (currently 5.2.6). You may need to change $sDriver parameter in your connection command to "MySQL ODBC 5.2 Unicode Driver" instead of leaving it default. Your command should be read as:

_MySQLConnect($MYSQLUserName, $MYSQLPassword, $MYSQLDatabase, $MySQLServerName, "{MySQL ODBC 5.2 Unicode Driver}", 3306)

2. You can use driver 3.51, but change an option to force Mysql using UTF-8 encoding to store and receive value. Execute this below line right after your connection is successfully established :

_Query($SQLQuery, "SET NAMES utf8")
Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

Link to post
Share on other sites
  • 1 month later...

hi guy

i try to use  mysqludf function  but  have  always  this 

MySQL.au3 (132) : ==> The requested action with this object has failed.:

$baseprice=$pricelist_1_baseprice=$pricelist_2_baseprice

    Dim $TableName = "dynarc_gmart_items"
    Dim $ColumnNames[62]
    Dim $NewGuest[62]

;   $ColumnNames[0] = "id"
    $ColumnNames[0] = "uid"
    $ColumnNames[1] = "gid"
;   $ColumnNames[2] = ""

    $ColumnNames[2] = "_mod"
    $ColumnNames[3] = "cat_id"
    $ColumnNames[4] = "lnk_id"
    $ColumnNames[5] = "lnkarc_id"
    $ColumnNames[6] = "name"
    $ColumnNames[7] = "description"
    $ColumnNames[8] = "keywords"
    $ColumnNames[9] = "ordering"
    $ColumnNames[10] = "trash"
    $ColumnNames[11] = "ctime"
    $ColumnNames[12] = "mtime"
    $ColumnNames[13] = "published"
    $ColumnNames[14] = "hierarchy"
    $ColumnNames[15] = "brand"
    $ColumnNames[16] = "brand_id"
    $ColumnNames[17] = "model"
    $ColumnNames[18] = "barcode"
    $ColumnNames[19] = "manufacturer_code"
    $ColumnNames[20] = "qty_sold"
    $ColumnNames[21] = "units"
    $ColumnNames[22] = "aliasname"
    $ColumnNames[23] = "code_num"
    $ColumnNames[24] = "code_str"
    $ColumnNames[25] = "code_ext"
    $ColumnNames[26] = "md5"
    $ColumnNames[27] = "baseprice"
    $ColumnNames[28] = "vat"
    $ColumnNames[29] = "pricelist_1_baseprice"
    $ColumnNames[30] = "pricelist_1_marate"
    $ColumnNames[31] = "pricelist_1_vat"
    $ColumnNames[32] = "pricelist_2_baseprice"
    $ColumnNames[33] = "pricelist_2_marate"
    $ColumnNames[34] = "pricelist_2_vat"
    $ColumnNames[35] = "storeqty"
    $ColumnNames[36] = "booked"
    $ColumnNames[37] = "incoming"
    $ColumnNames[38] = "loaded"
    $ColumnNames[39] = "downloaded"
    $ColumnNames[40] = "thumb_img"
    $ColumnNames[41] = "thumb_img_2"
    $ColumnNames[42] = "thumb_img_3"
    $ColumnNames[43] = "thumb_img_4"
    $ColumnNames[44] = "thumb_img_5"
    $ColumnNames[45] = "thumb_img_6"
    $ColumnNames[46] = "idocs"
    $ColumnNames[47] = "store_1_qty"
    $ColumnNames[48] = "store_2_qty"
    $ColumnNames[49] = "store_3_qty"
    $ColumnNames[50] = "store_4_qty"
    $ColumnNames[51] = "pricelist"
    $ColumnNames[52] = "weight"
    $ColumnNames[53] = "weightunits"
    $ColumnNames[54] = "item_location"
    $ColumnNames[55] = "pricelist_1_vendorprice"
    $ColumnNames[56] = "pricelist_1_cm"
    $ColumnNames[57] = "pricelist_1_discount"
    $ColumnNames[58] = "pricelist_2_vendorprice"
    $ColumnNames[59] = "pricelist_2_cm"
    $ColumnNames[60] = "pricelist_2_discount"
    $ColumnNames[61] = ""



    ;$NewGuest[0] = $id
    $NewGuest[0] = $uid
    $NewGuest[1] = $gid
;   $NewGuest[2] = ""


    $NewGuest[2] = $_mod
    $NewGuest[3] = $cat_id
    $NewGuest[4] = $lnk_id
    $NewGuest[5] = $lnkarc_id

$k=$k+1

    ;$NewGuest[6] = '- '&$string[$k] ;$name
    $NewGuest[6] = $string[$k] ;$name

    $NewGuest[7] = $string[$k] ;$description

    $NewGuest[8] = $keywords
    $NewGuest[9] = $ordering
    $NewGuest[10] = $trash

    $NewGuest[11] = $ctime
    $NewGuest[12] = $mtime

    $NewGuest[13] = $published
    $NewGuest[14] = $hierarchy

    $NewGuest[15] = "- " ;$brand

    $NewGuest[16] = $brand_id
    $NewGuest[17] =  $string[$k] ; $model

    $NewGuest[18] = $barcode
    $NewGuest[19] = $manufacturer_code
    $NewGuest[20] = $qty_sold
    $NewGuest[21] = $units
    $NewGuest[22] = $aliasname
    $NewGuest[23] = $code_num

    $k=$k-1
    $NewGuest[24] = $string[$k];$code_str

    $NewGuest[25] = $code_ext
    $NewGuest[26] = $md5

    $k=$k+3
    $NewGuest[27] = $string[$k] ; $baseprice

    $NewGuest[28] = $vat

    $NewGuest[29] = $string[$k] ;$pricelist_1_baseprice

    $NewGuest[30] = $pricelist_1_marate
    $NewGuest[31] = $pricelist_1_vat

    $NewGuest[32] = $string[$k] ;$pricelist_2_baseprice
    $NewGuest[33] = $pricelist_2_marate

    $NewGuest[34] = $pricelist_2_vat

    $k=$k-1
    $NewGuest[35] = $string[$k] ;$storeqty

    $NewGuest[36] = $booked
    $NewGuest[37] = $incoming
    $NewGuest[38] = $loaded
    $NewGuest[39] = $downloaded
    $NewGuest[40] = $thumb_img
    $NewGuest[41] = $thumb_img_2
    $NewGuest[42] = $thumb_img_3
    $NewGuest[43] = $thumb_img_4
    $NewGuest[44] = $thumb_img_5
    $NewGuest[45] = $thumb_img_6
    $NewGuest[46] = $idocs
    $NewGuest[47] = $store_1_qty
    $NewGuest[48] = $store_2_qty
    $NewGuest[49] = $store_3_qty
    $NewGuest[50] = $store_4_qty
    $NewGuest[51] = $pricelist
    $NewGuest[52] = $weight
    $NewGuest[53] = $weightunits
    $NewGuest[54] = $item_location
    $NewGuest[55] = $pricelist_1_vendorprice
    $NewGuest[56] = $pricelist_1_cm
    $NewGuest[57] = $pricelist_1_discount
    $NewGuest[58] = $pricelist_2_vendorprice
    $NewGuest[59] = $pricelist_2_cm
    $NewGuest[60] = $pricelist_2_discount
    $NewGuest[61] = ""


    $SQLInstance = _MySQLConnect($UserName, $Password, $Database, $MySQLServerName)

    _AddRecord($SQLInstance, $TableName, $ColumnNames, $NewGuest)
    _MySQLEnd($SQLInstance)
Link to post
Share on other sites

Faustf,

Few things:

1. Put an error handler so you know what exactly the error message is.

See

2. $ColumnNames[61] = "" and $NewGuest[61] = "" why not just Dim $ColumnNames[61] and Dim $NewGuest[61] instead of Dim $ColumnNames[62] and Dim $NewGuest[62] ?

3. First line: $baseprice=$pricelist_1_baseprice=$pricelist_2_baseprice

You dont try to assign a value to $baseprice at this way, do you?

Use MsgBox or ConsoleWrite to see what is the content of $baseprice after that first line

Link to post
Share on other sites

i tryed  to simplified  

    Dim $TableName = "dynarc_gmart_items"
    Dim $ColumnNames[3]
    Dim $NewGuest[3]


    $ColumnNames[0] = "uid"
    $ColumnNames[1] = "gid"
    $ColumnNames[2] = ""


$NewGuest[0] = 2;$uid
    $NewGuest[1] = 5;$gid
    $NewGuest[2] = ""


$SQLInstance = _MySQLConnect($UserName, $Password, $Database, $MySQLServerName)

    _AddRecord($SQLInstance, $TableName, $ColumnNames, $NewGuest)
    _MySQLEnd($SQLInstance)

but  give me  the same  error   :((((   why ???

Edited by faustf
Link to post
Share on other sites

i try to  understund  what happen 

i   insert a  message box   in  mysql.au3  , because  i  wanna   see  the  sql  string  (if  is correct or  not )

i saw  the  mysql.au3  insert a  error 

the  sql  is    insert into dynarc_gmart_items(uid,gid)values(,2,5);

insert a  comma  ,  before  a  2 , is not  correct  , and  db dont  accept  , with out  first  comma  go 

Link to post
Share on other sites

i have  modify   the  mysql.au3  

Func _AddRecord($oConnectionObj, $sTable, $vRow, $vValue = "")

    If IsObj($oConnectionObj) Then
        $query = "INSERT INTO " & $sTable & " ("

        If IsArray($vRow) Then
            For $i = 0 To UBound($vRow, 1) - 1
                If $i > 0 And $i <> UBound($vRow, 1) - 1 Then
                    $query = $query & "," & $vRow[$i] & ""
                ElseIf $i = UBound($vRow, 1) - 1 And $vRow[$i] <> "" Then
                    $query = $query & "," & $vRow[$i] & ") VALUES("
                ElseIf $i = 0 Then
                    $query = $query & "" & $vRow[$i] & ""
                ElseIf $vRow[$i] = "" Then
                    $query = $query & ") VALUES("
                EndIf
            Next
        EndIf
        If Not IsArray($vRow) And Not IsArray($vValue) And Not IsInt($vValue) Then
            $oConnectionobj.execute ("INSERT INTO " & $sTable & " (" & $vRow & ") VALUES('" & $vValue & "')")
            return 1
        ElseIf IsInt($vValue) And Not IsArray($vRow) And Not IsArray($vValue) Then
            $oconnectionobj.execute ("INSERT INTO " & $sTable & " (" & $vRow & ") VALUES(" & $vValue & ")")
            return 1
        EndIf

        If IsArray($vValue) Then

            For $i = 0 To UBound($vValue, 1) - 1
                If $i > 0 And $i <> UBound($vValue, 1) - 1 And Not IsInt($vValue[$i]) Then
                    $query = $query & ",'" & $vValue[$i] & "'"
                ElseIf $i = UBound($vValue, 1) - 1 And $vValue[$i] <> "" And Not IsInt($vValue[$i]) Then
                    $query = $query & ",'" & $vValue[$i] & "');"
                ElseIf $i = 0 And Not IsInt($vValue[$i]) Then
                    $query = $query & "'" & $vValue[$i] & "'"
                ElseIf $vValue[$i] = "" Then
                    $query = $query & ");"
                ElseIf IsInt($vValue[$i]) And $vValue[$i] <> "" Then

                    $query = $query & "," & $vValue[$i]

                EndIf

            Next
        EndIf
        If StringRight($query, 2) <> ");" Then
            $query = $query & ");"

        EndIf

        Local $text = StringReplace($query, "(,", "(")
        $oconnectionobj.execute ($text)

    EndIf
    If Not IsObj($oConnectionObj) Then
        SetError(2)
        Return 0
    EndIf
    If @error And IsObj($oConnectionObj) Then
        Return 0
        SetError(1)
    Else
        Return 1
    EndIf

EndFunc   ;==>_AddRecord

insert a  string replace  in  function addrecord

in this  mode  go correct

Link to post
Share on other sites
  • 7 months later...

Hello cdkid,

many thanks for this great UDFs. They work very fine in my environment and it is easy to use. For time reasons I did not read the complete thread here and I am not shure if someone did see the following issues.

First I found one minor error :

_AddRecord Function : if the first value is integer, the inserted values starts with ",". I added two more lines like :

ElseIf $i = 0 And IsInt($vValue[$i]) Then
       $query = $query & $vValue[$i]

 

I needed some extensions so I have to do it by myself.

1. You can also create tables without primary key. So I added a new funcion for me. If you are interest in, I can send you my code via eMail.

2. The result of _Query can have more then one result in one line. So the program has to do more work like :

Dim $ret[1][1], $rs
$rs = _Query($oMyCon, "select * from adresse")
With $rs
    $nLaenge = $rs.Fields.Count
    While Not .EOF
        ReDim $ret[uBound($ret, 1) + 1][$nLaenge]
        For $i = 0 To $nLaenge - 1
            $ret[uBound($ret, 1) - 1][$i] = $rs.Fields ($i).Value
        Next
        .MoveNext
    WEnd
EndWith
$ret[0][0] = UBound($ret, 1) - 1
For $i = 1 To UBound($ret,1) -1
    For $j = 0 To UBound($ret,2) -2
        ConsoleWrite($ret[$i][$j]&",")
    Next
    ConsoleWrite($ret[$i][uBound($ret,2) -1]&@CRLF)
Next

After that I have a question :

Is it possible to catch the Error message from MySQL and bring it also in a field so that I can directly view it in the MsgBox.
 

Link to post
Share on other sites
  • 2 weeks later...

Got this up and running for me.

Works great after I figured out a few double quote issues with my query. 

My only wish and I am sure there is a way to do it (I just hope simple) rather than run my query to a .txt file and have minimal control of how to write the data and then later use a FileRead to a MsgBox or something.

What is a neat way to display results where I can have a traditional table look similar to how it would look when using a DB client or Excel.

Id like to keep it native to AutoIt not actually push the data to Excel or something.

Link to post
Share on other sites
  • 2 weeks later...

Got this up and running for me.

Works great after I figured out a few double quote issues with my query. 

My only wish and I am sure there is a way to do it (I just hope simple) rather than run my query to a .txt file and have minimal control of how to write the data and then later use a FileRead to a MsgBox or something.

What is a neat way to display results where I can have a traditional table look similar to how it would look when using a DB client or Excel.

Id like to keep it native to AutoIt not actually push the data to Excel or something.

 

You can use this code (edit from Solack's code above) to save query result to 2 dimension array, which is easier to manipulate and show

#include <Array.au3>
#include <mysql.au3>
Dim $ret[1][1], $rs
$rs=_Query($sql,$command)
With $rs
    $nLaenge = $rs.Fields.Count ; get count of fields

; add fields value to 2 dimension array
    While Not .EOF
        ReDim $ret[UBound($ret, 1) + 1][$nLaenge]
        For $i = 0 To $nLaenge - 1
            $ret[UBound($ret, 1) - 1][$i] = $rs.Fields ($i).value
        Next
        .MoveNext
     WEnd
     ; add fields name to first row of array, must run below fields value because the redim is there
For $i = 0 To $rs.Fields.Count -1
    $ret[0][$i]=$rs.Fields($i).name
 Next

EndWith

 _ArrayDisplay($ret)

Result will be like this ( i removed the name's value from image)

W6K5ZJ7.png

Link to post
Share on other sites

Looks good :)

Also is there a way to call a value directly (say msgbox) 

My most recent script looks like this and I am using MsgBox to show the results to people, the file write worked well for me in this situation but I still want to learn a good way to call direclty to my results.  If I tried to plug Fields.XXX.Value in a MsgBox I get an error. 

#include <mysql.au3>

$FO = FileOpen("C:\kbox3.txt", 2)
$kname = InputBox("Black Magic Tools", "Please Enter Name To Check in KBOX", "Your Name First or Last")
$kdate = InputBox("Black Magic Tools", "Please Enter Date to check FROM (Start)", "MM/DD/YY")
$kdate2 = InputBox("Black Magic Tools", "Please Enter Date to check TO (End)", "MM/DD/YY")
$sql = _MySQLConnect("snip for security")
$var = _Query($sql, "Select USER.FULL_NAME AS 'Tech Name', SUM(TIMESTAMPDIFF(minute, HD_WORK.START, HD_WORK.STOP)/60) AS 'Range Hours', SUM(HD_WORK.ADJUSTMENT_HOURS) AS 'Adjusted Hours' from HD_WORK INNER JOIN USER ON USER.ID=HD_WORK.USER_ID WHERE USER.FULL_NAME LIKE '%" & $kname & _
"%' AND HD_WORK.MODIFIED BETWEEN STR_TO_DATE('" & $kdate & " 00:00:01', '%m/%d/%y %H:%i:%s') AND STR_TO_DATE('" & $kdate2 & " 23:59:59', '%m/%d/%y %H:%i:%s') GROUP BY USER.FULL_NAME;")

With $var
While NOT .EOF
FileWriteLine($FO,.Fields("Tech Name").value & @CRLF & .Fields("Range Hours").value & @CRLF & .Fields("Adjusted Hours").value)
.MoveNext
WEnd
EndWith

FileSetPos($FO, 0, 0)
$contents = FileRead($FO)

If StringInStr($contents, $kname) Then
    FileSetPos($FO, 0, 0)
    $line1 = FileReadLine($FO, 1)
    FileSetPos($FO, 0, 0)
    $line2 = FileReadLine($FO, 2)
    FileSetPos($FO, 0, 0)
    $line3 = FileReadLine($FO, 3)
    $linetotal = ($line2 + $line3)

    MsgBox(0, "Black Magic Tools", $line1 & @CRLF & "Hours Worked From - " & $kdate & " To " & $kdate2 & @CRLF & @CRLF & _
    "Hours Logged From Start & End Time: " & StringLeft($line2, StringInStr($line2, ".")+2) & @CRLF & _
    "Adjusted Hours Manually Entered: " & StringLeft($line3, StringInStr($line3, ".")+2) & @CRLF & @CRLF & _
    "Total Hours: " & StringLeft($linetotal, StringInStr($linetotal, ".")+2))


Else
    MsgBox(0, "Black Magic Tools", $kname & " Not found in Database")
EndIf


FileClose($FO)
_MySQLEnd($sql)
Link to post
Share on other sites

You can use this code (edit from Solack's code above) to save query result to 2 dimension array, which is easier to manipulate and show

#include <Array.au3>
#include <mysql.au3>
Dim $ret[1][1], $rs
$rs=_Query($sql,$command)
With $rs
    $nLaenge = $rs.Fields.Count ; get count of fields

; add fields value to 2 dimension array
    While Not .EOF
        ReDim $ret[UBound($ret, 1) + 1][$nLaenge]
        For $i = 0 To $nLaenge - 1
            $ret[UBound($ret, 1) - 1][$i] = $rs.Fields ($i).value
        Next
        .MoveNext
     WEnd
     ; add fields name to first row of array, must run below fields value because the redim is there
For $i = 0 To $rs.Fields.Count -1
    $ret[0][$i]=$rs.Fields($i).name
 Next

EndWith

 _ArrayDisplay($ret)

Result will be like this ( i removed the name's value from image)

W6K5ZJ7.png

 

Just noticed if my query has no results I get an error is there a good @Error to use so I can give a "No Results" message instead of an application error?

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. 

Edited by ViciousXUSMC
Link to post
Share on other sites
  • 4 weeks later...

Just a friendly update, still wondering if there is a way to get a proper "no results" when the search returns nothing.

New script we are using to check our daily hours:

#include <Array.au3>
#include <mysql.au3>


$kname = @UserName
$kdate = @MON & "/" & @MDAY & "/" & StringRight(@YEAR, 2)
$kdate2 =@MON & "/" & @MDAY & "/" & StringRight(@YEAR, 2)

Dim $ret[1][1], $rs

$sql = _MySQLConnect("xx", "xxxxx", "xxxxx", "xxxxxxxxxx")
$rs=_Query($sql,"Select USER.FULL_NAME AS 'Tech Name', ROUND(SUM(TIMESTAMPDIFF(minute, HD_WORK.START, HD_WORK.STOP)/60), 2) AS 'Range Hours', ROUND(SUM(HD_WORK.ADJUSTMENT_HOURS), 2) AS 'Adjusted Hours', " & _
"ROUND(SUM(TIMESTAMPDIFF(minute, HD_WORK.START, HD_WORK.STOP)/60) + SUM(HD_WORK.ADJUSTMENT_HOURS), 2) AS 'Total Hours' from HD_WORK INNER JOIN USER ON USER.ID=HD_WORK.USER_ID WHERE USER.USER_NAME LIKE '%" & $kname & _
"%' AND HD_WORK.STOP BETWEEN STR_TO_DATE('" & $kdate & " 00:00:01', '%m/%d/%y %H:%i:%s') AND STR_TO_DATE('" & $kdate2 & " 23:59:59', '%m/%d/%y %H:%i:%s') GROUP BY USER.FULL_NAME;")
With $rs
    $nLaenge = $rs.Fields.Count ; get count of fields

; add fields value to 2 dimension array
    While Not .EOF
        ReDim $ret[UBound($ret, 1) + 1][$nLaenge]
        For $i = 0 To $nLaenge - 1
            $ret[UBound($ret, 1) - 1][$i] = $rs.Fields ($i).value
        Next
        .MoveNext
     WEnd
     ; add fields name to first row of array, must run below fields value because the redim is there
For $i = 0 To $rs.Fields.Count -1
    $ret[0][$i]=$rs.Fields($i).name
 Next

EndWith

 _ArrayDisplay($ret, "Hours Worked Summary", "", 64)

I wonder if the answer would be to use ubound in some way for the array, it may prevent the error but not sure how to tie that into a "no results" message.  So the @Error would still be valid if possible for me.

Link to post
Share on other sites
  • 3 months later...

I must be missing something, but I think it would be good if the original post could be updated to better reflect the driver download instructions. README says to download... err... something? The link takes you to a page with 4 files to choose from, none of which clearly contains a "driver EXE" with which to rename to "driversetup.exe". Next step is "Then compile". Compile what? An exe isn't source to compile.

Link to post
Share on other sites
  • 5 months later...

Are there plans to add Update Record?

 

I am building a database by hand right now to track the status/location of computers and I want to keep each computer listed as a primary key and update the records when they relocate instead of creating a new record.  For now I guess I can use delete record and then re-add it but it feels a bit dirty and that means I have to put back every field even if I only intend to update a couple.

 

 

Edited by ViciousXUSMC
Link to post
Share on other sites

Are there plans to add Update Record?

I am building a database by hand right now to track the status/location of computers and I want to keep each computer listed as a primary key and update the records when they relocate instead of creating a new record.  For now I guess I can use delete record and then re-add it but it feels a bit dirty and that means I have to put back every field even if I only intend to update a couple.

update mytable set mycolumn = 'new value' where PC_ID = 'the PC ID';

This is a standard SQL statement which you just execute, see *Exec function.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
  • 1 year later...

Hi, sorry if i'm posting here but this is a UDF from here so i don't want to start new topic.

I'm getting this error when i press button to login with valid or invalid data its same, to my localhost database:

mysql.au3" (27) : ==> The requested action with this object has failed.:
$Objconn.open ("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword & ";PORT="&$iPort)
$Objconn^ ERROR

 

Here is my code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "mysql.au3"

#Region ### START Koda GUI section ###
$Form1 = GUICreate("Form1", 418, 582, 444, 186)
$db_host = GUICtrlCreateInput("Database host", 120, 64, 153, 21)
$db_user = GUICtrlCreateInput("Database username", 120, 96, 153, 21)
$db_pass = GUICtrlCreateInput("Database password", 120, 128, 153, 21)
$db_name = GUICtrlCreateInput("Database name", 120, 160, 153, 21)
$connect = GUICtrlCreateButton("Connect", 120, 200, 153, 25)
$status = GUICtrlCreateLabel("Status : Idle", 16, 16, 385, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $connect
            __MYCONNECT()

    EndSwitch
WEnd



Func __MYCONNECT()

    Local $host = GUICtrlRead($db_host)
    Local $username = GUICtrlRead($db_user)
    Local $password = GUICtrlRead($db_pass)
    Local $database_name = GUICtrlRead($db_name)

    _MySQLConnect($username, $password, $database_name, $host)

    If @error = 1 Then
        GUICtrlSetData($status, "Status : Error opening connection.")
    ElseIf @error = 2 Then
        GUICtrlSetData($status, "Status : MySQL ODBC Driver not installed.")
    Else
        GUICtrlSetData($status, "Status : Connected.")
    EndIf
EndFunc

 

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...