Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Moderators
Posted

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.

Visit...Bassic Software
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...