khang0001 Posted February 28, 2011 Share Posted February 28, 2011 (edited) I have the database name a b c d e khang 1 2 3 4 5 tuan 6 7 8 9 10 minh 11 12 13 14 15 toan 16 17 18 19 20 tan 21 22 23 24 25 I want to search the column and the row ex : if khang and e the result is 5 if tan and c the result is 23 if minh and d the result is 14 please help me how can i search the string in database my database is sqlite Edited February 28, 2011 by khang0001 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 28, 2011 Moderators Share Posted February 28, 2011 Would help to know what kind of database it is. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
khang0001 Posted February 28, 2011 Author Share Posted February 28, 2011 my database is sqlite in autoit Link to comment Share on other sites More sharing options...
saywell Posted February 28, 2011 Share Posted February 28, 2011 (edited) The sql is:SELECT e FROM [tablename] WHERE name= 'khang';Look in the helpfiles [uDFs - SQLite Management] for how to run that in autoit.William Edited February 28, 2011 by saywell Link to comment Share on other sites More sharing options...
wolf9228 Posted February 28, 2011 Share Posted February 28, 2011 (edited) I have the database name a b c d e khang 1 2 3 4 5 tuan 6 7 8 9 10 minh 11 12 13 14 15 toan 16 17 18 19 20 tan 21 22 23 24 25 I want to search the column and the row ex : if khang and e the result is 5 if tan and c the result is 23 if minh and d the result is 14 please help me how can i search the string in database my database is sqlite #Include <Date.au3> #include <SQLite.au3> #include <SQLite.dll.au3> FileDelete("Database.db") Dim $hQuery , $aRow _SQLite_Startup () $DatabaseH = _SQLite_Open("Database.db") _SQLite_Exec (-1, "CREATE TABLE iTABLE (name,a,b,c,d,e);") _SQLite_Exec (-1, "INSERT INTO iTABLE (name,a,b,c,d,e) VALUES ('khang','1','2','3','4','5');") _SQLite_Exec (-1, "INSERT INTO iTABLE (name,a,b,c,d,e) VALUES ('tuan','6','7','8','9','10');") _SQLite_Exec (-1, "INSERT INTO iTABLE (name,a,b,c,d,e) VALUES ('minh','11','12','13','14','15');") _SQLite_Exec (-1, "INSERT INTO iTABLE (name,a,b,c,d,e) VALUES ('toan','16','17','18','19','20');") _SQLite_Exec (-1, "INSERT INTO iTABLE (name,a,b,c,d,e) VALUES ('tan','21','22','23','24','25');") $BOOL = TableSearch($DatabaseH,"iTABLE","name,e","'khang','5'") MsgBox(0,"",$BOOL) $BOOL = TableSearch($DatabaseH,"iTABLE","name,a,b,c,d,e","'tuan','6','7','8','9','10'") MsgBox(0,"",$BOOL) $BOOL = TableSearch($DatabaseH,"iTABLE","name,e","'khang','100'") MsgBox(0,"",$BOOL) $BOOL = TableSearch($DatabaseH,"iTABLE","name,a,b,c,d,e","'tuan','6','7','8','9','200'") MsgBox(0,"",$BOOL) Func TableSearch($DatabaseH,$iTABLE,$ColumnsList,$ValuesList) $SplitColumns = StringSplit($ColumnsList,",") $SplitValues = StringSplit($ValuesList,",") if $SplitColumns[0] <> $SplitValues[0] Then Return SetError(1,0,False) For $i = 1 To $SplitColumns[0] _SQlite_Query($DatabaseH, "SELECT " & $SplitColumns[$i] & " FROM " & $iTABLE & " WHERE " & $SplitColumns[$i] & " = " & $SplitValues[$i] & ";", $hQuery) if _SQLite_FetchData ($hQuery, $aRow) <> $SQLITE_OK Then Return SetError(2,0,False) Next Return SetError(0,0,True) EndFunc Edited February 28, 2011 by wolf9228 صرح السماء كان هنا 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