Jump to content

Recommended Posts

Posted

Hello, I'm trying to put the results of a mysql query into a combo box. The problem is that it is all coming out together. For example: JimJohnFredJohnsonSamWheat

Cheers

Func Myquery()
    $NameList1 = ""
        $NametoFind = GUICtrlRead($Input1) & "%"
    $RemoteFormatString = "SELECT * FROM hardware WHERE userid LIKE '%s'"
    $SQLCode = StringFormat($RemoteFormatString, $NametoFind)
    $TableContents = _Query($SQLInstance, $SQLCode)
    With $TableContents
        While Not .EOF
            $NameList1 &= .Fields("name" ).value & @CRLF
            .MoveNext
        WEnd
    EndWith
    GUICtrlSetData($Input1, $NameList1);setting to combobox
    _MySQLEnd($SQLInstance)
    MsgBox(0, "TestOutput", $NameList1)
EndFunc   ;==>DisplayTable
Posted (edited)

$NameList1 &= "|" & .Fields("name" ).value ;; No @CRLF for a list or Combo

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

Glad to be of assistance.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

One more question. When it populates the combo box it looks blank until I click on the drop down box. Is there a way to have the first result showing in the combo box so the user can see that the search is done?

Cheers

Posted

$sDefault = StringRegExpReplace($NameList1, "^\|(.+?)\|.+", "$1")
GUICtrlSetData($MyList, $nameList1, $sDefault)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

I think I maybe doing this wrong. So should it run after the query? Thanks for your help.

Func Mac()
    $SQLInstance3 = _MySQLConnect($UserName, $Password, $Database, $MySQLServerName) 
    $Mac1 = ""
    $NametoFind2 = GUICtrlRead($Userid)
    $RemoteFormatString2 = 'SELECT * FROM networks WHERE (hardware_id = "%s")'
    $SQLCode3 = StringFormat($RemoteFormatString2, $NametoFind2)
    $TableContents3 = _Query($SQLInstance3, $SQLCode3)
    With $TableContents3
        While Not .EOF
            $Mac1 &= "|" & .Fields("macaddr" ).value 
            .MoveNext
        WEnd
    EndWith
    GUICtrlSetData($MACAddressCombo, $Mac1)
    sleep(1000)
    ;;
    $sDefault = StringRegExpReplace($MACAddressCombo, "^\|(.+?)\|.+", "$1")
    GUICtrlSetData($Mac1, $MACAddressCombo, $sDefault)
    ;;
    _MySQLEnd($SQLInstance3)
    ;MsgBox(0, "DEBUG", $Mac1);Debug
EndFunc   ;==>Mac

$sDefault = StringRegExpReplace($NameList1, "^\|(.+?)\|.+", "$1")
GUICtrlSetData($MyList, $nameList1, $sDefault)

Posted (edited)

Func Mac()
    Local $SQLInstance3 = _MySQLConnect($UserName, $Password, $Database, $MySQLServerName) 
    Local $Mac1 = ""
    Local $NametoFind2 = GUICtrlRead($Userid)
    Local $RemoteFormatString2 = 'SELECT * FROM networks WHERE (hardware_id = "%s")'
    Local $SQLCode3 = StringFormat($RemoteFormatString2, $NametoFind2)
    Local $TableContents3 = _Query($SQLInstance3, $SQLCode3)
    With $TableContents3
        While Not .EOF
            $Mac1 &= "|" & .Fields("macaddr" ).value 
            .MoveNext
        WEnd
    EndWith
    Local $sDefault = StringRegExpReplace($Mac1, "^\|(.+?)\|.+", "$1")
    GUICtrlSetData($MACAddressCombo, $Mac1, $sDefault)
    ;;
    _MySQLEnd($SQLInstance3)
    ;MsgBox(0, "DEBUG", $Mac1);Debug
EndFunc   ;==>Mac

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

Excellent it works great. Thanks again

Func Mac()
    Local $SQLInstance3 = _MySQLConnect($UserName, $Password, $Database, $MySQLServerName) 
    Local $Mac1 = ""
    Local $NametoFind2 = GUICtrlRead($Userid)
    Local $RemoteFormatString2 = 'SELECT * FROM networks WHERE (hardware_id = "%s")'
    Local $SQLCode3 = StringFormat($RemoteFormatString2, $NametoFind2)
    Local $TableContents3 = _Query($SQLInstance3, $SQLCode3)
    With $TableContents3
        While Not .EOF
            $Mac1 &= "|" & .Fields("macaddr" ).value 
            .MoveNext
        WEnd
    EndWith
    Local $sDefault = StringRegExpReplace($Mac1, "^\|(.+?)\|.+", "$1")
    GUICtrlSetData($MACAddressCombo, $Mac1, $sDefault)
    ;;
    _MySQLEnd($SQLInstance3)
    ;MsgBox(0, "DEBUG", $Mac1);Debug
EndFunc   ;==>Mac

Posted

Glad to help and happy it works for you.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

  • 4 weeks later...

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...