PDA

View Full Version : Help with SQL and Database Retrieval


tcampbel
03-09-2001, 09:17 AM
Hello,

Is there anyone who could assist me on how to retrieve data from and SQL Database using an search or find button. This information is already showing in a DTC Grid. I need to now how to take an user request from an search input text box and make it query the database and fill the grid with the query information.

Thanks

Tony Hawk
03-09-2001, 11:34 AM
That really isn't as easy as it may sound. Assuning you are using a Perl script to do the work and you have DBI installed on your server you could do something like this:

use DBI;
$dbh = DBI->connect("dbi:mysql:$mysqldatabase","$mysqlusername","$mysqlpassword") || die("Couldn't connect to database!\n");
my($query) = "SELECT * FROM tablename WHERE (WHATEVER LIKE '%$SEARCHSTRING%')";
my($sth) = $dbh->prepare($query);
$sth->execute || die("Couldn't exec sth!");

A little confusing at first but once you get the hang of it, you'll love it!

Good luck!

tcampbel
03-09-2001, 01:46 PM
Thanks Tony,

I do not have DBI loaded and I am not using Perl Script. The development tool that I am using is Visual Interdev 6.0.
I am developing this application on a local webserver (Win2000 Professional). So I would have no ideal where any of that would go.


Thanks again..

Tom Brown
03-11-2001, 10:27 PM
Ok,
using vbscript will work for you

To use a text box you simply need to do a
request.form("textbox_name") in the string you are using to build your sql statement. example

sql = select * from tablename where name = '"&request.form("textbox_name")&"'
dbconnect.open sql

good luck.
Tom