Sql server 2008 driver info

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fran7
    New Member
    • Jul 2006
    • 229

    Sql server 2008 driver info

    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

    gstrConnectToDa tabase = "Provider=SQLOL EDB; Data Source=mssql2ho st.com; Initial Catalog=databas e; User ID=me; Password=passme "
    Code:
    
    <%
    Set dataNow = Server.CreateObject("ADODB.Connection") 
    dataNow.Open("Driver={MySQL ODBC 3.51 Driver};Server=ms.host.com;DATABASE=test;USER=user;PASSWORD=1rich-TOP;OPTION=3")
    dataNow.execute("SET NAMES 'utf8'")
    
    lastID = Request.QueryString("lastID")
    action = Request.QueryString("action")
    Set RS999=Server.CreateObject("ADODB.RecordSet")
    
    'We need to include the JS files and other standard HTML files here in order not to load them in every scroll.
    If action <> "getLastPosts" Then 
    %>
    	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    	<html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    	<title>Untitled Document</title>
    	</head>
    	<link rel="stylesheet" href="css.css" type="text/css" />
    	<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
    	
    	<script type="text/javascript">
    	$(document).ready(function(){
    		
    		$('form#mainForm').bind('submit', function(e){
    			e.preventDefault();
    			checkForm();
    		});
    		
    		$('input#hostName').focus();
    	
    		
    		function lastPostFunc() 
    		{ 
    			$('div#lastPostsLoader').html('<img src="bigLoader.gif">');
    			$.post("scroll.asp?action=getLastPosts&lastID="+$(".wrdLatest:last").attr("id"),
    	
    			function(data){
    				if (data != "") {
    				$(".wrdLatest:last").after(data);			
    				}
    				$('div#lastPostsLoader').empty();
    			});
    		};  
    		
    		$(window).scroll(function(){
    			if  ($(window).scrollTop() == $(document).height() - $(window).height()){
    			   lastPostFunc();
    			}
    		}); 
    		
    	});
    	</script>
    	
    	
    	<body>
    	
    <%
    		'The content loaded when the page is first loaded start
    		SQL="SELECT * FROM test ORDER BY testID DESC LIMIT 20"
    		RS999.Open SQL,dataNOW,1,1
    		While Not RS999.EOF
    %>
    			<div class="wrdLatest" id="<%=RS999("testID")%>">
    				<div class="xtop"><div class="xb1"></div><div class="xb2"></div><div class="xb3"></div><div class="xb4"></div></div>
    				<div class="xboxcontent">
    					<%=RS999("testName")%>
    				</div>
    				<div class="xbottom"><div class="xb4"></div><div class="xb3"></div><div class="xb2"></div><div class="xb1"></div></div>
    			</div>
    		<%
    		RS999.MoveNext
    		Wend
    		RS999.Close
    		'The content loaded when the page is first loaded end
    		%>
    		
    		<div id="lastPostsLoader">
    		
    	</body>
    	</html>
    		
    <%	
    Else
    	'When User Scrolls This Query Is Run Start
    	getPostsText = ""
    	SQL="SELECT * FROM test WHERE testID < "&lastID&" ORDER BY testID DESC LIMIT 5"
    	RS999.Open SQL,dataNOW,1,1
    	While Not RS999.EOF
    
    		getPostsText = getPostsText & "<div class=""wrdLatest"" id=""" & RS999("testID") & """>"
    		getPostsText = getPostsText & "<div class=""xtop""><div class=""xb1""></div><div class=""xb2""></div><div class=""xb3""></div><div class=""xb4""></div></div>"
    		getPostsText = getPostsText & "<div class=""xboxcontent"">" & RS999("testName") & "</a></div>"
    		getPostsText = getPostsText & "<div class=""xbottom""><div class=""xb4""></div><div class=""xb3""></div><div class=""xb2""></div><div class=""xb1""></div></div></div>"
    
    	RS999.MoveNext
    	Wend
    	RS999.Close
    	Response.Write getPostsText 'Writes The Result Of The Query
    	'When User Scrolls This Query Is Run End
    End If
    %>
    Last edited by fran7; Dec 20 '12, 08:16 PM. Reason: forgot some info
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    This page lists different connection strings for SQL Server 2008.
    Connection strings for SQL Server 2008. Connect using Microsoft.Data.SqlClient, SqlConnection, SQLNCLI11 OLEDB, SQLNCLI10 OLEDB, ODBC Driver 17 for SQL Server.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      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.

      Comment

      • fran7
        New Member
        • Jul 2006
        • 229

        #4
        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


        Code:
        Set dataNow = Server.CreateObject("ADODB.Connection")
        dataNow.Open("Provider=SQLNCLI10;Server=mss.com;Database=name;Uid=me;Pwd=me123;OPTION=3 ")

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          In SQL Server, you use top instead of limit. And in a different place.
          Code:
          select top 100 * from table

          Comment

          Working...