discountasp.net connection string problems

Discussion in 'Classic ASP' started by DKSW, Sep 1, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I used to have a different web host which allowed me to have a dsn - that way I just referenced the dsn and gave a password and my classic asp code worked fine - it looked like this:

    dim SQLstmt
    SQLstmt = "select * from table"
    Set rs = Server.CreateObject ("ADODB.Recordset")
    With rs
    '.Open SQLstmt, "DSN=MYDSNNAME;UID=MYUSERID_sa;PWD=MYPASSWORD"
    End With

    but it appears that discountasp.net does not have or allow for a dsn

    i saw the article at

    http://support.discountasp.net/KB/a356/how-to-query-sql-database-with-asp-using-dsn-less-connection.aspx?KBSearchID=198193

    so I modified my code to look like this

    set cn = Server.CreateObject("ADODB.Connection")
    cn.Open "Provider=SQLOLEDB;" _
    & "Data Source=sql***.discountasp.net;Initial Catalog=MYDATABASE;User Id=MYUSER;Password=MYPASSWORD;" _
    & "Connect Timeout=15;Network Library=dbmssocn;"
    Dim SQLstmt
    SQLstmt = "select * from WebForms"
    set rs = cn.Execute(SQLstmt)

    but when I tried to use that code it could not create the connection object getting an error 800a01f4 saying "variable is undefined: cn"

    how can I get my classic asp database connection working with my database that is on the discountasp.net sql2008r2 database?

    I NEED HELP - I didn't anticipate this issue and my website is currently not working
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    I created a test page that connect to sql 2k8 r2 and here's the code

    <%

    Dim cnnSimple ' ADO connection
    Dim rstSimple ' ADO recordset
    Set cnnSimple = Server.CreateObject("ADODB.Connection")

    ' DSNLess
    cnnSimple.Open ("Provider=sqloledb;Data Source=sql2k804;Initial Catalog=SQL2008R2_xxxxx;User Id=SQL2008R2_xxxxx;Password=xxxx" )

    Set rstSimple = cnnSimple.Execute("SELECT * FROM sysobjects")

    %>
    <P> Connecting to Access with Ole connection </P>

    <table border="1">
    <%
    Do While Not rstSimple.EOF
    %>
    <tr>
    <td><%= rstSimple.Fields(0).Value %></td>
    <td><%= rstSimple.Fields(1).Value %></td>
    </tr>
    <%
    rstSimple.MoveNext
    Loop
    %>
    </table>
    <%

    rstSimple.Close
    Set rstSimple = Nothing
    cnnSimple.Close
    Set cnnSimple = Nothing


    %>
     
  3. bruce, for me the code does not work.. i couldn't have missed any points.. something wrong..
     
  4. Herer is the mistake
    <table border="1">
    <%
    Do While Not rstSimple.EOF
    %>
    <tr>
    <td><%= rstSimple.Fields(0).Value %></td>
    <td><%= rstSimple.Fields(1).Value %></td>
    </tr>
    <%
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page