Jump to content

SQL - Search


Recommended Posts

I created 2 input boxes and 1 button.

$searchinput = textbox that will be used to search

$nameinput = textbox that will be displaying the result. (I'm not using a label because I'm going to impliment it later on to modify data and save records)

$searchb1 = the button to press when search is ready.

Goal: type an employee name on the searchinput and press the search button. If employee name exist, show it on the nameinput textbox.

Func SearchUser()
$query_name = "SELECT * from employers where Full_Name = '%" & $searchinput & "%'"
$exe_name = _Query($SQLOBJ, $query_name)

with $exe_name
    while NOT .EOF
GUICtrlSetData($nameinput, .Fields('Full_Name').value)
.MoveNext
WEnd
EndWith
EndFunc

I tested with the msgbox and it works fine.

Can someone show me the official way on how to get this to work with the textbox? I'm using the sql.au3.

thanks,

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

I created 2 input boxes and 1 button.

$searchinput = textbox that will be used to search

$nameinput = textbox that will be displaying the result. (I'm not using a label because I'm going to impliment it later on to modify data and save records)

$searchb1 = the button to press when search is ready.

Goal: type an employee name on the searchinput and press the search button. If employee name exist, show it on the nameinput textbox.

Func SearchUser()
$query_name = "SELECT * from employers where Full_Name = '%" & $searchinput & "%'"
$exe_name = _Query($SQLOBJ, $query_name)

with $exe_name
    while NOT .EOF
GUICtrlSetData($nameinput, .Fields('Full_Name').value)
.MoveNext
WEnd
EndWith
EndFunc

I tested with the msgbox and it works fine.

Can someone show me the official way on how to get this to work with the textbox? I'm using the sql.au3.

thanks,

maybe if .Fields('Full_Name').value <> "" then GUICtrlSetData($nameinput, .Fields('Full_Name').value)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

maybe if .Fields('Full_Name').value <> "" then GUICtrlSetData($nameinput, .Fields('Full_Name').value)

I'm seeing result, but wrong result. Say I search 'John', it came out Kathy. Any search comes out the same result Kathy.

Nevermind, I got it...

$query_name = "SELECT * from employers WHERE Full_Name like '%" & GUICtrlRead($searchinput) & "%'"
$exe_name = _Query($SQLOBJ, $query_name)

 

Forgot to add GUICtrlRead

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...