Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TK GUI working with SQL

Status
Not open for further replies.

cyphrix

Programmer
Nov 16, 2006
27
0
0
US
I have built a GUI in Tk that is supposed to take user input and search an MS SQL database. I am about 3/4 complete, however, I cannot seem to get the script to search for what the user wants. I need a way to actually assign what is entered into the Entry box (or multiple Entry boxes) to a variable(s) and then have the script search the SQL for that and that only. As of right now, whichever Entry box the user types something in, the script merely fetches EVERYTHING in that row and prints to screen. (nearly 5000 items each). Though there are multiple entry boxes, I will post what one looks like right now:


Code:
$ZWIDGETS{'Entry1'}=$ZWIDGETS{Frame2}->Entry(
     -width => 60,
     -textvariable = \$Location,
     )->grid(
     -row => 2,
     -column => 1,
     -sticky => 'nw',
     -pady => 5,
     );

There are 11 more of the same types of entry boxes above, each for different queries.

How do I take the user input in these boxes and somehow get it into a SQL query so that it will return exactly what they ask for instead of fetching the entire row?

Do I give FetchRow() and argument?

Thanks for any help in advance.
 
Ok, I have run some more tests...I think my problem lies in my query.

If I understand the above, -textvariable is assigning the text typed into the entry box to the variable $Location. If this is true, then from there, I don't know how to build the SQL Query correctly.

Right now, my query is

Code:
my $SQL = "SELECT LocationAlpha FROM dbo.mydatabase WHERE LocationAlpha = $Location";

From running this, I am getting an error stating that the text assigned to variable $Location is not a valid column so I now understand that the query above is basically saying: "Select column LocationAlpha from the database where column LocationAlpha is equal to $whatever_was_assigned_to_the_location_variable.

So now, my question is, how do I use the SQL query to access specific data within a column?

Sorry if this has confused anyone thus far. Its my first time using Perl to access a database, let alone using a Tk GUI as an interface to do it.

-Josh
 
nevermind...figured it out on my own.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top