By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

Sql server 2008 driver info

100+
P: 229
Hi, I have this working fine from a mysql database. I am trying to use it from a sql server 2008 database but cannot get it working, just error 500. Does anyone know how the driver info might have to change or is there anything else in the code that might be mysql specific?
Thanks for any help in advance
Richard


the connection strung that works with my other pages is below but not sure how to adapt the mysql to it

gstrConnectToDatabase = "Provider=SQLOLEDB; Data Source=mssql2host.com; Initial Catalog=database; User ID=me; Password=passme"
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <%
  4. Set dataNow = Server.CreateObject("ADODB.Connection") 
  5. dataNow.Open("Driver={MySQL ODBC 3.51 Driver};Server=ms.host.com;DATABASE=test;USER=user;PASSWORD=1rich-TOP;OPTION=3")
  6. dataNow.execute("SET NAMES 'utf8'")
  7.  
  8. lastID = Request.QueryString("lastID")
  9. action = Request.QueryString("action")
  10. Set RS999=Server.CreateObject("ADODB.RecordSet")
  11.  
  12. 'We need to include the JS files and other standard HTML files here in order not to load them in every scroll.
  13. If action <> "getLastPosts" Then 
  14. %>
  15.     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  16.     <html xmlns="http://www.w3.org/1999/xhtml">
  17.     <head>
  18.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  19.     <title>Untitled Document</title>
  20.     </head>
  21.     <link rel="stylesheet" href="css.css" type="text/css" />
  22.     <script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
  23.  
  24.     <script type="text/javascript">
  25.     $(document).ready(function(){
  26.  
  27.         $('form#mainForm').bind('submit', function(e){
  28.             e.preventDefault();
  29.             checkForm();
  30.         });
  31.  
  32.         $('input#hostName').focus();
  33.  
  34.  
  35.         function lastPostFunc() 
  36.         { 
  37.             $('div#lastPostsLoader').html('<img src="bigLoader.gif">');
  38.             $.post("scroll.asp?action=getLastPosts&lastID="+$(".wrdLatest:last").attr("id"),
  39.  
  40.             function(data){
  41.                 if (data != "") {
  42.                 $(".wrdLatest:last").after(data);            
  43.                 }
  44.                 $('div#lastPostsLoader').empty();
  45.             });
  46.         };  
  47.  
  48.         $(window).scroll(function(){
  49.             if  ($(window).scrollTop() == $(document).height() - $(window).height()){
  50.                lastPostFunc();
  51.             }
  52.         }); 
  53.  
  54.     });
  55.     </script>
  56.  
  57.  
  58.     <body>
  59.  
  60. <%
  61.         'The content loaded when the page is first loaded start
  62.         SQL="SELECT * FROM test ORDER BY testID DESC LIMIT 20"
  63.         RS999.Open SQL,dataNOW,1,1
  64.         While Not RS999.EOF
  65. %>
  66.             <div class="wrdLatest" id="<%=RS999("testID")%>">
  67.                 <div class="xtop"><div class="xb1"></div><div class="xb2"></div><div class="xb3"></div><div class="xb4"></div></div>
  68.                 <div class="xboxcontent">
  69.                     <%=RS999("testName")%>
  70.                 </div>
  71.                 <div class="xbottom"><div class="xb4"></div><div class="xb3"></div><div class="xb2"></div><div class="xb1"></div></div>
  72.             </div>
  73.         <%
  74.         RS999.MoveNext
  75.         Wend
  76.         RS999.Close
  77.         'The content loaded when the page is first loaded end
  78.         %>
  79.  
  80.         <div id="lastPostsLoader">
  81.  
  82.     </body>
  83.     </html>
  84.  
  85. <%    
  86. Else
  87.     'When User Scrolls This Query Is Run Start
  88.     getPostsText = ""
  89.     SQL="SELECT * FROM test WHERE testID < "&lastID&" ORDER BY testID DESC LIMIT 5"
  90.     RS999.Open SQL,dataNOW,1,1
  91.     While Not RS999.EOF
  92.  
  93.         getPostsText = getPostsText & "<div class=""wrdLatest"" id=""" & RS999("testID") & """>"
  94.         getPostsText = getPostsText & "<div class=""xtop""><div class=""xb1""></div><div class=""xb2""></div><div class=""xb3""></div><div class=""xb4""></div></div>"
  95.         getPostsText = getPostsText & "<div class=""xboxcontent"">" & RS999("testName") & "</a></div>"
  96.         getPostsText = getPostsText & "<div class=""xbottom""><div class=""xb4""></div><div class=""xb3""></div><div class=""xb2""></div><div class=""xb1""></div></div></div>"
  97.  
  98.     RS999.MoveNext
  99.     Wend
  100.     RS999.Close
  101.     Response.Write getPostsText 'Writes The Result Of The Query
  102.     'When User Scrolls This Query Is Run End
  103. End If
  104. %>
  105.  
Dec 20 '12 #1

✓ answered by Rabbit

This page lists different connection strings for SQL Server 2008.
http://www.connectionstrings.com/sql-server-2008

Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,430
This page lists different connection strings for SQL Server 2008.
http://www.connectionstrings.com/sql-server-2008
Dec 20 '12 #2

NeoPa
Expert Mod 15k+
P: 31,768
I'm not sure you can determine which line the error occurred on Richard, but that is helpful if you have it and the text of the error message is also useful (and expected when posting a question relating to an error).

I expect Rabbit's link will prove helpful anyway, but please remember to include these items in your questions.
Dec 20 '12 #3

100+
P: 229
Hi, Thanks for the replies, I found the connection string in the link you posted, thanks. I also found the error in the code is that "limit" is not supported in sql.
Thanks
Richard


Expand|Select|Wrap|Line Numbers
  1. Set dataNow = Server.CreateObject("ADODB.Connection")
  2. dataNow.Open("Provider=SQLNCLI10;Server=mss.com;Database=name;Uid=me;Pwd=me123;OPTION=3 ")
  3.  
Dec 20 '12 #4

Rabbit
Expert Mod 10K+
P: 12,430
In SQL Server, you use top instead of limit. And in a different place.
Expand|Select|Wrap|Line Numbers
  1. select top 100 * from table
Dec 21 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.