Print Page | Close Window

convert mod 2 sql

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=8700
Printed Date: 30 March 2026 at 7:27am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: convert mod 2 sql
Posted By: Badaboem
Subject: convert mod 2 sql
Date 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)

 




Replies:
Posted By: michael
Date 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.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Badaboem
Date 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.


Posted By: Badaboem
Date 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.



Posted By: michael
Date 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$$

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Badaboem
Date 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.




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