Jump to content
Sign in to follow this  
Queener

SQL - Search

Recommended Posts

Queener

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

Share this post


Link to post
Share on other sites
mikell

This SQL.au3 is obsolete since AutoIt3 has now the SQLite.au3 file provided in the install

Share this post


Link to post
Share on other sites
argumentum

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)

Share this post


Link to post
Share on other sites
Queener

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.