JamesDover Posted October 20, 2010 Share Posted October 20, 2010 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 Link to comment Share on other sites More sharing options...
GEOSoft Posted October 20, 2010 Share Posted October 20, 2010 (edited) $NameList1 &= "|" & .Fields("name" ).value ;; No @CRLF for a list or Combo Edited October 20, 2010 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!" Link to comment Share on other sites More sharing options...
JamesDover Posted October 20, 2010 Author Share Posted October 20, 2010 Thank you for your quick response. It works perfectly.Cheers$NameList1 &= "|" & .Fields("name" ).value ;; No @CRLF for a list or Combo Link to comment Share on other sites More sharing options...
GEOSoft Posted October 20, 2010 Share Posted October 20, 2010 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!" Link to comment Share on other sites More sharing options...
JamesDover Posted October 26, 2010 Author Share Posted October 26, 2010 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 Link to comment Share on other sites More sharing options...
GEOSoft Posted October 26, 2010 Share Posted October 26, 2010 $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!" Link to comment Share on other sites More sharing options...
JamesDover Posted October 27, 2010 Author Share Posted October 27, 2010 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) Link to comment Share on other sites More sharing options...
GEOSoft Posted October 27, 2010 Share Posted October 27, 2010 (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 October 27, 2010 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!" Link to comment Share on other sites More sharing options...
JamesDover Posted October 27, 2010 Author Share Posted October 27, 2010 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 Link to comment Share on other sites More sharing options...
GEOSoft Posted October 27, 2010 Share Posted October 27, 2010 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!" Link to comment Share on other sites More sharing options...
russell Posted November 19, 2010 Share Posted November 19, 2010 Can you post the whole script please. So i can study it for my projects. muppet hands are so soft :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now