Print Page | Close Window

recordset problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=15763
Printed Date: 30 March 2026 at 1:37am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: recordset problem
Posted By: urko
Subject: recordset problem
Date Posted: 08 July 2005 at 8:04am
Hi all
Need some help with this1 Smile
i have made recordset for news on main page.
<%
Dim news
Dim news_numRows
Set news = Server.CreateObject("ADODB.Recordset")
news.ActiveConnection = MM_artek_STRING
news.Source = "SELECT * FROM news_"& Session("lang") + " ORDER BY ID DESC"
news.CursorType = 0
news.CursorLocation = 2
news.LockType = 1
news.Open()

news_numRows = 0
%>

The thing is, I have mulitlanguage page therefor I have some problems with writing right recordset in detail page. (Table names in db: news_si and news_en)



Detail page recordset:
<%
Dim news
Dim news_numRows

Set news = Server.CreateObject("ADODB.Recordset")
news.ActiveConnection = MM_artek_STRING
news.Source = "SELECT * FROM news_"& Session("lang") don't know what to write here exactly
news.CursorType = 0
news.CursorLocation = 2
news.LockType = 1
news.Open()

news_numRows = 0
%>

Now what I would like is, that once you click on the news ( let say ID=4) to go to news.asp?ID=4,  but when i click the link, it goes to ID=1.
At the moment I add 4 news. On main page I only display last news, on the news page all news are displayed.

Also in news.asp page, where all news links alre dispalyed it will go to ID=1.
I think I should right somethin for URL parameters, but I just dont know how.

Thanks,



-------------
Urko



Replies:
Posted By: Scotty32
Date Posted: 08 July 2005 at 9:55am
news.Source = "SELECT * FROM news_"& Session("lang") + " ORDER BY ID DESC"

^^ the '+' is wrong should of been another '&'

also, if the Session("lang") isnt set, you'll get problems

so id suggestion doing

strLang = Session("lang")
if isNull(strLang) then strLang = "Default Lang Name"


news.Source = "SELECT * FROM news_" & strLang & " ORDER BY ID DESC"


as for the links you need to put the whole link, including the page
eg "news.asp?ID=1" not just "ID=1" though "?ID=1" would of worked but if your on "default.asp" and use "?ID=1" it'll take you to "default.asp?ID=1" so its best to use the page name aswell


hope that helps


-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: urko
Date Posted: 08 July 2005 at 10:17am
Ok,

I have wrote my post a little wrong so my apologiez Wink.
The first recordset ( default page )is working partly, cuz once u click on a news link it will always point you to the first news in news.asp page entered in DB.

I have made complete link in default page: <a href="news.asp?ID=<%=(news.Fields.Item("id").Value)%>"><%=(news.Fields.Item("title").Val ue)%>


The news.asp page is the one I'm having bigger problems!

The thing is that I have made 2 recordsets in news.asp page! ( news and news1)-
first one(news) is for displaying Title, text and image of the specific news u have clicked and second(news1) to display only news title of all news that are in DB!

So what I would need is only to fix the recordset so it will point you to the right ID not always to #1 ( in default page and news.asp page), cuz Session("lang") is set and working fine.

Here are my recordsets in news.asp page:
<%
Dim news
Dim news_numRows

Set news = Server.CreateObject("ADODB.Recordset")
news.ActiveConnection = MM_artek_STRING
news.Source = "SELECT * FROM news_"& Session("lang") -as far as I was reading I must add something here but don't know what Confused
news.CursorType = 0
news.CursorLocation = 2
news.LockType = 1
news.Open()

news_numRows = 0
%>



<%
Dim news1
Dim news1_numRows

Set news1 = Server.CreateObject("ADODB.Recordset")
news1.ActiveConnection = MM_artek_STRING
news1.Source = "SELECT * FROM news_"& Session("lang") -as far as I was reading I must add something here but don't know what Confused
news1.CursorType = 0
news1.CursorLocation = 2
news1.LockType = 1
news1.Open()

news1_numRows = 0
%>



-------------
Urko


Posted By: urko
Date Posted: 08 July 2005 at 10:34am
I did itTongueTongueTongue it works nowClapClap
I add 
news.Source = "SELECT * FROM news_"& Session("lang")  & " WHERE ID = " + Replace(news__MMColParam, "'", "''") + ""
to my recordset (news) in news.asp page and everyting works now.

But if you guys have an easier solution not so complicated please tell me, so i will knowTongue.




-------------
Urko


Posted By: Scotty32
Date Posted: 09 July 2005 at 7:26am
personally id still make sure theres a Session("lang") value set

so its best to have the way i said

and am not quite sure wots going on with "news__MMColParam"

if you want your page to show the news artical you clicked on you do

intNewsID = Request.QueryString("ID")
if isNumeric(intNewsID) then intNewsID = clng(intNewsID) else intNewsID = 0


this will get the number from "news.asp?id=1"
the if isNumeric() is a security check to stop people hacking your site

so you'd have:

news.Source = "SELECT * FROM news_" & strLang  & " WHERE ID = " & intNewsID & ";"



-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: urko
Date Posted: 09 July 2005 at 7:37am
Much better Big smile.

Slowly, I'm getting to know this stuff better and better!


thanks,


-------------
Urko



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net