[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.0

MS Access vs MS SQL 2005

Asked by Svjetlana in SQL Server 2005, Microsoft Access Database, Active Server Pages (ASP)

Tags: ASP, IE 6.028, IE 6.0.29

I am having problem changing my database queries from MS Access to MS SQL 2005. Can someone please help me with the following ASP if-else-end if statements:

               if IsDate(objRecordSet("ExpDate")) then
                  expDate = "'" &  objRecordSet("ExpDate") & "'"
            else
                  expDate = "null"
            end if
      
            if IsDate(objRecordSet("PublishedDate")) then
                  pubDate = "'" & objRecordSet("PublishedDate") & "'"
            else
                  pubDate = "null"
            end if
            
            
In Ms Access inserting or updating ExpDate and PublishedDate recorsets work fine, but when the same code runs on MS SQLServer 2005 my dates are changed to American dates. For example it was:

MsAccess
ExpDate = 12/02/2009
PublishedDate = 12/08/2008

and now in MS SQLServer 2005 I get:
02/12/2009
08/12/2008

My SQL query is:

 dbConn.Execute("Insert Into Files (Title, SectionId, UserId, Description, Comments, CheckOut, MajorVersion, MinorVersion, URL, DLCId, CreateDate, Message, BaseFileId, PreviousFileId, CheckOutDate, CurrentFile, CreatorId, LastPopBy, intLinks, extLinks, iLinkCount, eLinkCount) values ('" & Replace(objRecordSet("Title"), "'", "''") & "'," & objRecordSet("SectionId") & "," &  uId & ",'" & objRecordSet("Description") & "','" & cmt & "',1," & ver & ",0,'-', 1 ,GetDate()," & expDate & "," & pubDate & ",'" & Replace(objRecordSet("Message"),"'","''") &  "'," & bFileId & "," & objRecordSet("FileId") & ",GetDate(), 1," & objRecordSet("CreatorId") & "," & objRecordSet("LastPopBy") & ",'" &  replace(objRecordSet("intLinks"), "'", "") & "','" & replace(objRecordSet("extLinks") , "'", "") & "'," & objRecordSet("iLinkCount") & "," & objRecordSet("eLinkCount") & ")")

    set dbConn = server.createobject("ADODB.Connection")
      dbConn.Open "Driver={SQL Native Client};Server=sqldatabase;Database=db_13;Uid=db_13_dbo;Pwd=password;"

   dbConn.Execute("Update Files Set CurrentFile = 0 where FileId = " & objRecordSet("FileId"))
 
    set dbConn = server.createobject("ADODB.Connection")
      dbConn.Open "Driver={SQL Native Client};Server=sqldatabase;Database=db_13;Uid=db_13_dbo;Pwd=password;"

        Const adOpenStatic = 3
        Const adLockOptimistic = 3
        Const adUseClient = 3      
            
             set objNewFile = Server.CreateObject("Adodb.RecordSet")
            objNewFile.CursorLocation = adUseClient
        objNewFile.open "Select Max(FileId) as File from Files where BaseFileId = " & fid, dbConn, adOpenStatic, adLockOptimistic

                  if not objNewFile.eof then
                        newF = objNewFile("File")
                  end if


As you can see above, for some reason I have to open database connection (dbConn.Open) several times, otherwise I can't Select or Update my table data. The worst problem is when I try to create several queries in one if-else-end if statement it just wouldn't Select table data, for example:

set maxVer = server.createobject("ADODB.recordset")
set objRecordSet = server.createobject("ADODB.recordset")
set objTheFile = server.createobject("ADODB.recordset")
set objVerCnt = server.createobject("ADODB.recordset")

set objRecordSet  = dbConn.Execute("Select * from Files where FileId = " & fid)

if not objRecordSet.eof then
      if objRecordSet("BaseFileId") = 0 then
            qry  = "Select Max(MajorVersion) from Files where FileId = " & fid & " or BaseFileId = " & fid
            verQry = "Select Count(*) As versionCount from Files where (FileId = " & fid & " or BaseFileId = " & fid & ") and MajorVersion = " & ver
            delVerQry = "Delete From Files Where (FileId = " & fid & " or BaseFileId = " & fid & ") and MajorVersion = (Select Min(MajorVersion) from Files where FileId = " & fid & " or BaseFileId = " & fid &  ")"
            verExist = "Select Count(*) As versionCount from Files where FileId = " & fid & " or BaseFileId = " & fid
      else
            qry  = "Select Max(MajorVersion) from Files where FileId = " & fid & " or BaseFileId = " & objRecordSet("BaseFileId")
            verQry = "Select Count(*) As versionCount from Files where ( FileId = " & fid & " or BaseFileId = " & objRecordSet("BaseFileId") & ") and MajorVersion = " & ver
            delVerQry = "Delete From Files Where (FileId = " & fid & " or BaseFileId = " & objRecordSet("BaseFileId") & "or (FileId = " & objRecordSet("BaseFileId") & " and  BaseFileId = 0)) and MajorVersion = (Select Min(MajorVersion) from Files where FileId = " & fid & " or BaseFileId = " & objRecordSet("BaseFileId") & " or (FileId = " & objRecordSet("BaseFileId") & " and  BaseFileId = 0))"
            verExist = "Select Count(*) As versionCount from Files where  FileId = " & fid & " or BaseFileId = " & objRecordSet("BaseFileId")
      end if



Any pointers on how can I solve this issue would be much appreciated?

Thank you sooooo much.

Svjetlana


[+][-]08/25/08 04:09 PM, ID: 22310172Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 04:14 PM, ID: 22310195Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 04:34 AM, ID: 22313387Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/26/08 04:52 AM, ID: 22313502Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 05:38 AM, ID: 22313864Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 05:38 AM, ID: 22313872Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 05:52 AM, ID: 22313991Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 05:59 AM, ID: 22314058Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 06:40 AM, ID: 22314486Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 09:57 AM, ID: 22316868Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/26/08 10:06 AM, ID: 22316943Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: SQL Server 2005, Microsoft Access Database, Active Server Pages (ASP)
Tags: ASP, IE 6.028, IE 6.0.29
Sign Up Now!
Solution Provided By: cactus_data
Participating Experts: 3
Solution Grade: C
 
[+][-]08/26/08 01:37 PM, ID: 22319176Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/04/08 04:03 PM, ID: 22393714Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/10/08 04:11 PM, ID: 22444052Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/11/08 02:47 AM, ID: 22447726Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 / EE_QW_2_20070628