ebahammed Posted August 30, 2003 Posted August 30, 2003 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 that's returned by this query, I have to show as PDF, using Crystal Report. That's going to be another posting in this forum. Help me, you experts out there! I am learning. Thanks in advance. Quote
Moderators Robby Posted August 31, 2003 Moderators Posted August 31, 2003 You can try the following, I will prefix the variables so you'll understand the data type which are implied... 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. Quote Visit...Bassic Software
ebahammed Posted September 2, 2003 Author Posted September 2, 2003 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 Quote
ebahammed Posted September 3, 2003 Author Posted September 3, 2003 (edited) Thanks Robby! I took care of it. Edited September 3, 2003 by ebahammed Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.