Sign in to follow this  
Followers 0
JamesDover

Input Mysql output to a combobox

11 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  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!"

Share this post


Link to post
Share on other sites

Thank you for your quick response. It works perfectly.

Cheers

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

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

$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!"

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#8 ·  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!"

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!"

Share this post


Link to post
Share on other sites

Can you post the whole script please. So i can study it for my projects.


muppet hands are so soft :)

Share this post


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
Sign in to follow this  
Followers 0