Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - recordset problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

recordset problem

 Post Reply Post Reply
Author
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post Topic: recordset problem
    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
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post 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.




Edited by urko - 08 July 2005 at 10:40am
Urko
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post Posted: 09 July 2005 at 7:37am
Much better Big smile.

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


thanks,


Edited by urko - 09 July 2005 at 7:38am
Urko
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.