|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Updating a Large SQL Query
HI, I am updating over 100 fields in 7 tables with SQL in VB 6.0. The values will mostly come from check boxes. Do I need a VB variable to hold each value for my SQL query?
Also, what is the syntax for skipping an optional field? Do I just skip it and use comma's? I will never know which values are checked off so I cannot write code that will only insert my true values.
__________________
Best regards, Russ Bergen Senior Software Developer and Webmaster |
|
#2
|
|||
|
|||
|
If you are updating data you only need to specify the fileds that will be updated.
Update table set field1 = x, field3 = y ... Your first question will depend on what you are updating. Is this a timestamp or do each of the check boxes hold distinct values? Are the values derived? |
|
#3
|
|||
|
|||
|
Most of the values are boolean values: True or false. There are 100+ check boxes. When a check box is not checked, the value is false. I do not need to update the table if the value is false. If the check box is true, I need to enter "True" into that field. Therefore, I can have an unlimited number of variations with different check boxes checked for each new record.
With that in mind, you see that I cannot dynamically create an SQL query. I must have each field named in the Update part of the query. When I input the data, I want to skip most fields. Do I just use a , , , when I skip fields? Do I need a variable for each True value? |
|
#4
|
|||
|
|||
|
You can dynamically generate the SQL. If you are having to assign the boolean values, you already have knowledge of what columns and what tables will be updated. You could just create a matrix like if then else block.
|
|
#5
|
|||
|
|||
|
I thought about that but there are too many variables to do this. There are 100 variables. How would I get the placeholders to work? For instance if field 20, 40 and 60 are true and nothing else, how would I make an update? I only need to enter in true for those fields and the rest I can skip since they are not required. Can you show me some code?
|
|
#6
|
|||
|
|||
|
specify the field the control displays in the control's tag. then iterate through the controls adding that field to the list and that control's value as well.
__________________
Programmer's Corner |
|
#7
|
|||
|
|||
|
I think this is disabled in aspx, but in plain asp you can name fields just "1" or "2" and so on. I've done it before where you set the default to false, and then you do a for loop, and build the sql statement that way where if ischecked = true or however else you have the form set up, you just set that corresponding database variable = true.
I know i've done it where i have divs 1-5 for example. And a drop down menu was there and if they selected 4. i think it was this..... <body onload=set_all_display_to_none()> for (i=0;i<dropmenu.value;i++) document.getElementByID(i).display="inline" try and apply that and see if it works..... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Updating a Large SQL Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|