asp connection to SQL server DB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rjlorenzo
    New Member
    • Oct 2008
    • 16

    asp connection to SQL server DB

    Good Day,

    Just want to ask some help please, currently I'm using MS Access as my database but now I would like to use SQL DB as my database. Could anyone help me how to convert my connection string from ms access to sql db. below is my connection on ms access please do modification to work it on SQL. Many thanks in advance.
    Code:
    <%
    	dim strConn 
    	strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& server.MapPath("bts_db.mdb") &";Persist Security Info=False;Jet OLEDB:Database Password = prs"
    	function get_recordset(byval strSQL, byref recset)
    		on error resume next
    		set recset =  Server.CreateObject("ADODB.Recordset")
    		recset.open strSQL, strConn, 3
    		if err.number <> 0 then
    			Response.Write err.Description & "<br>"
    			Response.Write err.Source & "<br>"			
    			Response.Write strSQL
    			Response.End
    		end if
    		get_recordset = recset.recordcount
    	end function
    
    	sub Execute_Query (byval strSQL)
    		on error resume next
    		dim con
    		Set con = Server.CreateObject("adodb.Connection")
    		con.open strConn
    		con.BeginTrans
    		con.execute strSQL
    		if err.number <> 0 then
    			Response.Write err.Description & "<br>"
    			Response.Write err.Source & "<br>"
    			Response.Write strSQL & "<br>"
    			Response.End
    			con.RollbackTrans
    		else
    			con.CommitTrans
    		end if
    		Set con = nothing
    	end sub
    %>
    Last edited by jhardman; Dec 28 '09, 06:14 PM. Reason: added code tags
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    All connection strings in one place. Find the syntax for your database connection using ADO.NET, ADO, ODBC, OLEDB, C#, VB, VB.NET, ASP.NET and more.

    Comment

    Working...