Data Base query! Need Help! stat!

ebahammed

Member
Joined
Jul 21, 2003
Messages
13
Location
USA
Hello everybody,
I need help help! I am trying to create a query with different parameters, according to what users select!
I have a webform with 4 checkboxes, 2 listbox and 1 textBox and 2 buttons for Process and Clear.
If a user clicks 2 checkboxes, 2 listboxes become visible, with option of selecting a single item from the listboxes.
If user clicks on the 3rd checkbox, a textbox becomes visible for users input.
4th checkbox can also be checked by user to include total asset from a different table.

How do I create a SQL Server query with unknown number of fields/parameters that is used to get back a dataset.
I am new in programming and I know how to create simple SELECT queries with definite number of fields in design time. But no idea about creating SELECT queries in runtime with different fields , also from different tables!
From the dataset thats returned by this query, I have to show as PDF, using Crystal Report. Thats going to be another posting in this forum.
Help me, you experts out there! I am learning.
Thanks in advance.
 
You can try the following, I will prefix the variables so youll understand the data type which are implied...
Code:
dim s as string
s = "SELECT * FROM " & strTable & " WHERE FieldString1 = " & strVar1 & " AND FieldString2 = " & strVar2 & " AND FieldNum1 = " & intVar1 & " AND FieldNum2 < " & intVar2
Notice that string types need to be surrounded by single quotes and numbers do not.
 
Thanks Robby! I thought I replied earlier.
Anyway, an user can pick any order..1 checkbox and select an item from listbox & click Process OR type something in textBox and click Process OR select all checkboxes and type something in textBox and click Process.

Also, how do I create a connection string with 2 different server and databases? If possible.

I need help on this project. Thanks
 
Back
Top