Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - convert mod 2 sql
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

convert mod 2 sql

 Post Reply Post Reply
Author
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Topic: convert mod 2 sql
    Posted: 08 January 2004 at 4:53pm

Now that i've succeeded converting my forum to use sqlserver 2000, I wonder how easy/difficult it is to convert mods.

Do I have to create new stored procedures, or is it much simpler than that?

I'm starting with the news mod I use and would like to see one example of how to convert a sql statement, or any info that could help me on the way.

Here's part of the code and old sql statements..I have no idea where to start.



<!--#include virtual="/c4dportal2/forum/functions/functions_date_time_for mat.asp" -->
<!--#include virtual="/c4dportal2/forum/common.asp" -->
<%
'Create  DSN Less connection to Access Database
'Create DBConnection Object
Set DBConnection = Server.CreateObject("adodb.connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.Mappath("xx.mdb")
DBConnection.Open DSN

'Set amount of post to be displayed.
numnews = 9

'Set forum number to list news from
frmnum = 23

'The message will be truncated at the first space after this number of characters
intTruncate = 100000

'Count the Records

   SQLcount = "Select * From tblTopic Where Forum_ID ="&frmnum&" and Priority <1"
      Set RS = DBConnection.Execute(SQLcount)


 Select Case RS.eof
      Case False
        tempRSCount = RS.getrows
        Set RS = Nothing
        count = Cdbl(UBound(tempRSCount, 2)) + 1
                
     Case True
      count = "0"
 End Select
     Set RS = Nothing
    
       IF count > 0 Then
       IF count > numnews Then
       count = numnews
       Else
    End IF
     
      while not count = 0
      count = count - 1
     
  SQL = "Select * From tblTopic Where Forum_ID ="&frmnum&" and Priority <1 ORDER BY Topic_ID DESC"
      Set RS = DBConnection.Execute(SQL)

 



Edited by Badaboem
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2004 at 5:21pm
This page would work with SQL just as well, it is not necessary to create all sql statement to SProcs, nevertheless if you want to see an example, it could look like that for your first statement:

Select * From tblTopic Where Forum_ID ="&frmnum&" and Priority <1


Create Procedure mod_sp_gettopics
(
@forumID int
)
AS
Select * from tblTopics where ForumID = @forumID and Priority < 1
go

One thing, if you want to follow the MS SQL Server best practices, do not use Select * but use Select column1,column2, ....   explicitly.
Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2004 at 6:11pm
Thanks michael.. I think i will try those stored procedures, as it will save me some writing work in the future. Hopefully I'll get it right.
Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2004 at 10:02am

What have I done wrong here? I've tried to implement select column1, column2 etc.

In access the sql works, but in ms sql it doesn't. I've added common.asp to the code to make the database connection and deleted the access connection as well.

Item cannot be found in the collection corresponding to the requested name or ordinal

Set RS = server.CreateObject("ADODB.Recordset")
      SQL = "Select Subject, Start_Date, Topic_ID From tblTopic Where Forum_ID ="&frmnum&" and Priority <1 ORDER BY Topic_ID DESC"
      rs.Open strSQL, adoCon
            
        rs.move idc
        idc = idc + 1
         
         title = rs("Subject")
         date1 = rs("Start_Date")
         topicnum = rs("Topic_ID")

Title = rs("subject") and following lines create the error.

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2004 at 11:52am
Not sure, the syntax is right, did you verify that the table name is correct in SQL? Did you use the Access upsize wizard? I saw it once where it changed table names to dbo_tablename which was a big pain in the a$$
Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Posted: 10 January 2004 at 4:38am

I figured out what the issue was. Small mistake of having a virtual path to the common.asp file set wrong (access version) .

I've got it all fully working now.

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.