473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

select entire sql table but display specific cell with WHERE or LIKE condition

120 100+
im able to select & display all table data from sql database on to a webpage.
but when I use the response.write method is it possible to output a specific cell with a WHERE or LIKE condition?

currently im pulling out a specific cell using <% Response.Write objRS("Date_Band_1") %> but is it possible to do something like

<% Response.Write objRS("Date_Band_1" WHERE ID="1" ) %> ??

thanks in advance
Omar.
Mar 17 '10 #1

✓ answered by Soniad

Hi,

You dont need to open connection again and again .If Your ResultSet is more than 1 record then Use while loop to loop through records and display it on page.And I think when you are checking the condition "ID = 1" in SQL , Then obviously it will return only those row(s) whose ID is 1 ,Hence you don't need to check again in VBScript "if rs("id") = 1 then".

Regards,

"D"

5 4372
Soniad
66
Hi,

This is not possible.If u want to retrieve specific rows then use where condition in sql statement.
Can you specify what exactly you want to display on webpage. Means All data or specific data?

Regards,

"D"
Mar 17 '10 #2
omar999
120 100+
hey soniad : )

oh i see - thats a shame. this would mean me requesting each row's data turn by turn in individual sql statements - am i right?

is there any negative impact caused by more than 1 connection / request in the same asp page? as I need to display data from 38 rows

omar.
Mar 17 '10 #3
omar999
120 100+
I've found some more info on this matter which may help someone in the future

To only show records where id is 1 [or with a condition] using SQL:

Expand|Select|Wrap|Line Numbers
  1. sql= "select * from your_table_name where ID= 1"
  2.  
To manipulate a returned recordset:

Expand|Select|Wrap|Line Numbers
  1. if rs("id") = 1 then
  2. response.write something
  3. end if
  4.  
I have a sql db table with 38 rows of data - and I would like to dispay each row on a seperate html table using the manipulated recordset method

so far I've been able to select all from the table and use the manipulated recordset to display the first row. But I'm unable to display the second row? do I have to open up a new connection and query the database each time to display the second row and so forth? so I have to open and close the connection to the database 38 times?

this seems a bit long winded as I have to redeclare & rename variables 38 times.

thanks in advance
Omar.
Mar 18 '10 #4
Soniad
66
Hi,

You dont need to open connection again and again .If Your ResultSet is more than 1 record then Use while loop to loop through records and display it on page.And I think when you are checking the condition "ID = 1" in SQL , Then obviously it will return only those row(s) whose ID is 1 ,Hence you don't need to check again in VBScript "if rs("id") = 1 then".

Regards,

"D"
Mar 18 '10 #5
omar999
120 100+
thank you very much for the for loop idea. each record is dynamically creating itself within a table now.

my further question is - I'm trying to now allow each price/date to be updateable via a css popup box which then updates the record.

iv already got this working but I can only make 1 price/date box work - I have 38 price/box's and I can't get my head around how to make this process dynamic rather than the unneccesary 38 connection strings;

below is my code

Expand|Select|Wrap|Line Numbers
  1. <div id='PopUpLGWYYZ' style='display: none; position: absolute; left: 450px; top: 50px; border: solid black 1px; padding: 10px; background-color: rgb(255,255,225); text-align: justify; font-size: 12px; width: 210px;'>
  2. <form name="UKSpecialsUpdate" id="UKSpecialsUpdate" method="post" action="update.asp" />
  3. <table align="center" width="100%" cellpadding="0" cellspacing="0" style="margin:0">
  4.   <tr>
  5.     <td width="30%">Price</td>
  6.     <td>Outbound Date/s</td>
  7.   </tr>
  8.   <tr>
  9.     <td><input name="ID1PriceBand1" type="text" id="ID1PriceBand1" size="4" maxlength="4" value=""></td>
  10.     <td><input name="ID1DateBand1" type="text" id="ID1DateBand1" size="20" maxlength="100" value=""></td>
  11.   </tr>
  12.   <tr>
  13.     <td><input name="ID1PriceBand2" type="text" id="ID1PriceBand2" size="4" maxlength="4" value=""></td>
  14.     <td><input name="ID1DateBand2" type="text" id="ID1DateBand2" size="20" maxlength="100" value=""></td>
  15.   </tr>
  16.   <tr>
  17.     <td><input name="ID1PriceBand3" type="text" id="ID1PriceBand3" size="4" maxlength="4" value=""></td>
  18.     <td><input name="ID1DateBand3" type="text" id="ID1DateBand3" size="20" maxlength="100" value=""></td>
  19.   </tr>
  20.   <tr>
  21.     <td><input name="ID1PriceBand4" type="text" id="ID1PriceBand4" size="4" maxlength="4" value=""></td>
  22.     <td><input name="ID1DateBand4" type="text" id="ID1DateBand4" size="20" maxlength="100" value=""></td>
  23.   </tr>
  24.   <tr>
  25.     <td valign="middle"><div style='text-align: left;'><a onmouseover='this.style.cursor="pointer" ' style='font-size: 12px;' onfocus='this.blur();' onClick="document.getElementById('PopUpLGWYYZ').style.display = 'none' " ><span style="text-decoration: underline;">Close</span></a></div></td>
  26.     <td style="padding:20px 0 0 0" align="right"><input name="LGWYYZ" id="LGWYYZ" type="submit" value="Update!!"/></td>
  27.   </tr>
  28. </table>
  29. </form>
  30. </div>
  31.  
Expand|Select|Wrap|Line Numbers
  1. <%
  2.  
  3. If Request.Form("LGWYYZ") <> "" Then 
  4.  
  5. 'declare your variables
  6. Dim connection, sSQL, sConnString
  7. Price_Band_1=Request.Form("ID1PriceBand1")
  8. Date_Band_1=Request.Form("ID1DateBand1")
  9. Price_Band_2=Request.Form("ID1PriceBand2")
  10. Date_Band_2=Request.Form("ID1DateBand2")
  11. Price_Band_3=Request.Form("ID1PriceBand3")
  12. Date_Band_3=Request.Form("ID1DateBand3")
  13. Price_Band_4=Request.Form("ID1PriceBand4")
  14. Date_Band_4=Request.Form("ID1DateBand4")
  15.  
  16. 'declare SQL statement that will query the database
  17. sSQL="UPDATE MYTABLENAME SET Price_Band_1='" & Price_Band_1 & "', Date_Band_1='" & Date_Band_1 & "', Price_Band_2='" & Price_Band_2 & "', Date_Band_2='" & Date_Band_2 & "', Price_Band_3='" & Price_Band_3 & "', Date_Band_3='" & Date_Band_3 & "', Price_Band_4='" & Price_Band_4 & "', Date_Band_4='" & Date_Band_4 & "'  WHERE ID='1'"
  18.  
  19. 'create an ADO connection object
  20. Set connection = Server.CreateObject("ADODB.connection")
  21.  
  22. 'define the connection string, specify database
  23. 'driver and the location of database
  24. sConnString="myconnectionstringhere"
  25.  
  26. 'Open the connection to the database
  27. Connection.Open sConnString
  28.  
  29. 'Execute the SQL statement
  30. Connection.Execute sSQL
  31.  
  32. 'Now close the connection object
  33. connection.Close
  34. Set connection = Nothing
  35.  
  36. Response.write "Prices / Dates Updated! - Redirecting you back"
  37.  
  38. Else 
  39. Response.Write "Error! Nothing to Update!"
  40. END IF
  41. %>
  42.  
many thanks in advance
Omar.
Mar 19 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sqlnewbie | last post by:
I'm a newbie to script writing. I'm trying to write a script to copy all data from a table to the same table in a 2nd database. Both databases are on the same server and are identical in design. ...
2
by: alain.hogue | last post by:
I have a table "tblCards" with a field "Titre" that contain french words (Hébert, Gagné, Hélène, etc....) in an database with SQLEXPRESS 2005. I have used the asp:SqlDataSource to filter the...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
1
by: mikename | last post by:
Hi, I'm currently working on a project which is essentially a clickable world map. I have successfully mapped the image and using a OnMouseOver = "Continent()" OnMouseOut = "World()" command in...
6
by: Eugene F | last post by:
I am trying to figure out a single select statement from a table function f(x) when the function's argument is fed from another result set, like SELECT ... FROM TABLE( f(x) ) a where x is a...
2
by: pbd22 | last post by:
Hi, I am trying to create an update statement on a table with a foreign key to the Users table (userid). I am getting the error: An expression of non-boolean type specified in a context...
2
by: spacix | last post by:
Does anyone know a work around for "table-layout: fixed;" to prevent the automatic evenly space cells width without assigning classes or ID to cells? My program prints a HTML "report" file and I...
20
by: omar999 | last post by:
is it possible to perform a cast function on an entire table via sql? im basically trying to select all table contents multiply by 1.1 and then display the converted data on a webpage using sql,...
1
by: shalskedar | last post by:
I need to copy data from 1 workbook & paste to another workbook which i could do.. but i m not able to paste the data starting from the specific cell... Below is my code Dim wbk As Workbook...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.