|
I need to have my SQL perform a search on the following table:
Table: News
==================================================
PKID Source newsText newsURL|
==================================================
00001 Microsoft Something www.ms.com
00002 Sun Something www.sun.com
00003 Apple Something www.apple.com
...And so on
SELECT * FROM News
Would fill my recordset with all the fields from the News table. However in my site I have an options feature where users can select News by Source
Microsoft
Apple
Sun
Intel
Etc...
These options are stored in cookies and are later used in displaying the news. Depending on the news source options selceted only certain feilds should be displayed.
What would be the best way of doing this...?
Should I use seperate Select statements for each option checked...?
Like this?
If microsoftNews.checked = true Then
SELECT * From News WHERE Source = 'Microsoft'
'Iterate the recordset and display news items
Else If sunNews.checked = true Then
SELECT * FROM News WHERE Source = 'Sun'
'Iterate the recordset and display news items
Else If appleNews.checked = true Then
SELECT * FROM News WHERE Source = 'Apple'
'Iterate the recordset and display news items
End if 'Etc...
Or should I generate the entire SQL statement depending on options checked...?
I tried this earlier but it turned out to be harder than I desired.
I hope I explained myself clearly...
Any suggestions...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I am not sure if I've understood your question correctly... Is this what you are looking for?
Dim SQL, Keyword
Select Case True
Case microsoftNews.checked
Keyword = "Microsoft"
Case sunNews.checked
Keyword = "Sun"
Case appleNews.checked
Keyword = "Apple"
Case Else
Keyword = ""
End Select
SQL = "SELECT * From News WHERE Source = '" & Keyword & "'"
'Iterate the recordset and display news items
|
|
|
|
|
Nope, sorry!
The news feed should only display news by topic of interest (selected by user and stored in cookies).
So if Microsoft and Sun and Apple and Intel are checked AND AMD and Adobe and Claris are NOT checked, then I must construct some SQL statement on the fly according to the options set.
Select case True
Case microsfotNews.checked
Keyword = Keyword + "Microsoft"
...And so on...
I'm wondering if it would be easier to just use seperate SQL statments for each checkbox fill a recordset write it to screen and move onto the next...?
Sorry if i'm unclear, but it's super early in the morning and i'm just ready to goto sleep.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
You can try this
Select * from News Where Source In ('pref1', 'pref2', 'pref3', 'pref4', ...)
It may or may not be case sensitive, I think that depends on the database settings.
James
Simplicity Rules!
|
|
|
|
|
Well, then James is right and your code should look like this:
Dim SQL, Keywords
<br> <br>
Keywords = ""
<br> <br>
If microsoftNews.checked Then
Keywords = Keywords & "'Microsoft',"
End If
If sunNews.checked Then
Keywords = Keywords & "'Sun',"
End If
If appleNews.checked Then
Keywords = Keywords & "'Apple',"
End If
<br> <br>
If Len(Keywords) > 0 Then
' Remove last comma
Keywords = Left(Keywords, Len(Keywords) - 1)
End If
<br> <br>
SQL = "SELECT * From News WHERE Source IN (" & Keywords & ")"
'Iterate the recordset and display news items
|
|
|
|
|
Sweet i'll try it out and hope for the best.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hello,
I have been trying with no success to use this NewMail object on the
CDONTS library. It is very simple to script this, but I get a VBScript
Runtime error as follows:
'800a0046' Permission Denied
This occurs in my ASP page.
The script looks like:
dim oMail
set oMail = Server.CreateObject("CDONTS.NewMail")
oMail.Send "NoReply@www.abc.com", "abc@xyz.net"
Does anybody have any idea why I would get this runtime error when I execute the Send method?
Best Regards,
|
|
|
|
|
Hello:
How to open a password protected MS Access database using
ASP?
Is it possible at all?
Thanks in advance.
|
|
|
|
|
Dim strConn
' The following provider works for Access 97 and Access 2000, but
' is supposedly more stable w/ Access 2000.
' (In the db be sure Tools | References | Microsoft ActiveX Data Objects 2.5 Library is checked.)
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/mydbdir/mydb.asp") & ";Jet OLEDB:Database Password=mypassword;"
Best regards,
-Paul
Web Database Developer
To help you put live data on the Web...
http://www.Bullschmidt.com
|
|
|
|
|
I have a web page where I have text files (some with HTML commands included) that are loaded into a page using FSO. I can't get the text to wrap properly when it is loaded into a table - it just keeps extending across the page, pulling the whole layout out of whack. I have no idea why this happens, as the text theoretically should just wrap within the table.
What I am wondering is if anyone knows a way to go through the text file, and once say 80 characters has been exceeded, replace the next available space between words with a line break? and then keep going through all the text until each line is roughly 80 characters or so long. (I just don't want to end up cutting up any HTML commands) e.g. I wouldn't want to end up with <bod<br>Y>. Of course, if you had any lo-tech ideas as to fixing up the display of a text file read into a table, then that'd be just as good...
|
|
|
|
|
If you are using the FSO object then just append a "<br>" at the end of your WriteLine method.
HTH
Nick Parker
|
|
|
|
|
I want to create a web page where the user inputs
some number, I multiply that number by some special
number and it returns a new number. Here is the catch,
the special number is important to me and I don't
want other people to know what that number is. If I
just use java or simple html, anyone can go to Edit/
View Source and see my special number.
Is there any way of doing this? Or is there a way
to make html execute some simple c++ program and then
retrieve the number that it returns. I can easily write
something in c++ to multiple the user inputted number
with my number and return the new number, but I don't
know how to get html to execute a c++ file.
Any ideas? Any thoughts? Any code?
Any response you can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Well, you need to use some Server-Side scripting. ASP for example. But it depends on what your provider supports. It can be Perl, PHP or whatever. Ask your hosting provider what type of Server-side scripting languages he support.
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
If you have cgi enabled with your web provider you can program it in c++
<centre>
Now taking suggestions for a new sig. please email me all suggestions.
|
|
|
|
|
Is this special number for encryption...?
You can use cgi along with the POST(I think) method.
GET will show your special number in the URL bar which would be undesirable if your passing a credit card number or something else that secret.
However people can still view your data sent VIA POST using packet sniffers, only it's not as easy as URL encoded data.
So if your wanting to pass secret numbers to a cgi app on the server I think you would wanna use SSL.
I'm not sure I totally understood you here...however...
The response you got previously suggested you were after some way of storing your secret number in a CGI app on the server...
I don't think this will work either, cuz people can still view your perl scripts or php...on the server thus reveiling your secret number.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I wrote a small utility JScript cookie helper class thats posted here on CP. I'm using it in the development of my own site but I am also using ASP.
This is where the problem comes in...My cookie object stop working properlynow that i'm using ASP...
Do client/server cookies clash...?
Should I always use ASP for cookie managment...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
It depends on the context that you are trying to use the cookies to store information. I'm guessing you are having problems viewing cookie information (in ASP) that you created/modified on the client browser?
Software Developer
|
|
|
|
|
Hmm,
Cookies, cookies and more cookies.
In WinWorld ALL cookies created with InternetSetCookie / InternetGetCookie API's.
( except of may be Netscrape).
IIS/ASP sends cookies to the browser. Browser/webbrowserCtrl creates permanent cookies. Temporary cookies never written to HD.
InternetSetCookie takes URL. This is were it could falls appart.
http://127.0.0.1 could be different from http://your.com.pu.ter
To verify that your permanet cookies are working
Just call InternetGetCookie. For example:
bRet =
InternetGetCookie("http://www.yahoo.com",
NULL, sCookieVal, 10240)
Brian
|
|
|
|
|
has anybody figured out how to stop the ie6 image toolbar from popping up? not on my browser but on a users browser when they view my web site ... is there a script or whatever that can change the ie6 settings?
help appreciated
---
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
|
|
|
|
|
|
thanks
wasnt being lazy
didnt think to check google doh
---
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
|
|
|
|
|
lauren wrote:
wasnt being lazy
We wouldn't ever think a female would be lazy, what kind of guys do you think we are.
Nick Parker
This is a non-Calculus course as long as you know things like line integrals and surface integrals...
|
|
|
|
|
I am developing an application using ASP which updates a SQL server 2000 database on the back-end.
I currently have a bunch of HTML forms acting as the UI. Each form collects specific information that is stored in a different table, but I want all table inserts within the session to be part of one transaction (i.e. all or nothing).
I have tried a lot of things, but I still can't get a rollback to occur when a session times-out.
I've tried specifying -
"<%@ TRANSACTION=Requires_New Language=vbscript%>"
on the asp file with no success. I even tried explicitly calling the "ObjectContext.SetAbort" method.
My hosting company swears they have transactions enabled on thier servers, so I'm thinking it must be an error from my end.
I'll appreciate any help anyone could offer me. My question is how to handle transactions with multiple
Thank you
|
|
|
|
|
this could be a dumb question but here goes ... i saw a website where they had changed the standard scroll bars (vertical ones) to be a completely different look and feel that matched the web page much better ... is there a little bit of javascript or whatever that can do that at the client or is it a server side thing?
thanks
---
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
|
|
|
|
|
Lauren,
It can be done in the style tag at the top of the page.
<style>
BODY { scrollbar-3d-light-color:#999999;
scrollbar-arrow-color:#FFFF33;
scrollbar-base-color:black;
scrollbar-dark-shadow-color:#333333;
scrollbar-face-color:#666666;
scrollbar-highlight-color:#999999;
scrollbar-shadow-color:black}
</style>
Nick Parker
This is a non-Calculus course as long as you know things like line integrals and surface integrals...
|
|
|
|