Sample ASP Script??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chad Benjamin via SQLMonster.com

    Sample ASP Script??

    Hello,

    Im brand new and trying to learn SQL Server 2000, I have purchased a book
    and been reading it for a few weeks.

    I'm tring to find an ASP script that would let me know if my connection to
    my database is working.

    I use DSN, i created a DSN name "mail"

    anyone have any scripts?

    --
    Message posted via http://www.sqlmonster.com
  • John Bell

    #2
    Re: Sample ASP Script??

    Hi

    Check out:


    There are loads of things on that site which you will find useful.

    John

    "Chad Benjamin via SQLMonster.com" <forum@SQLMonst er.com> wrote in message
    news:96fc54d1d1 5b43f3ab5b707ec ee86301@SQLMons ter.com...[color=blue]
    > Hello,
    >
    > Im brand new and trying to learn SQL Server 2000, I have purchased a book
    > and been reading it for a few weeks.
    >
    > I'm tring to find an ASP script that would let me know if my connection to
    > my database is working.
    >
    > I use DSN, i created a DSN name "mail"
    >
    > anyone have any scripts?
    >
    > --
    > Message posted via http://www.sqlmonster.com[/color]


    Comment

    • Gregory Dean

      #3
      Re: Sample ASP Script??

      You really want to use DSN-less connections. Your code will be portable.

      But, to use your DSN connection you would do the following:

      <%
      dim cn
      set cn = Server.CreateOb ject("ADODB.Con nection")
      cn.ConnectionSt ring = "DSN=mail.d sn"
      cn.Open
      if cn.State <> 1 then
      Response.Write "Could not connect to database"
      else
      Response.Write "Connected! !"
      end if
      cn.Close
      set cn = nothing
      %>


      On 3/28/05 2:02 PM, in article
      96fc54d1d15b43f 3ab5b707ecee863 01@SQLMonster.c om, "Chad Benjamin via
      SQLMonster.com" <forum@SQLMonst er.com> wrote:
      [color=blue]
      > Hello,
      >
      > Im brand new and trying to learn SQL Server 2000, I have purchased a book
      > and been reading it for a few weeks.
      >
      > I'm tring to find an ASP script that would let me know if my connection to
      > my database is working.
      >
      > I use DSN, i created a DSN name "mail"
      >
      > anyone have any scripts?[/color]

      Comment

      • Toby Benjamin via SQLMonster.com

        #4
        Re: Sample ASP Script??

        Hi I tried your code you gave me but got an error.

        [Microsoft][ODBC Driver Manager] Data source name not found and no default
        driver specified


        any ideas?

        --
        Message posted via http://www.sqlmonster.com

        Comment

        • Gregory Dean

          #5
          Re: Sample ASP Script??

          That code was for a File DSN. You would need to change the code to include
          the full path to the file.

          A system DSN (probably what you are using) should look like this.

          cn.Open "DSN=mail;" & _
          "Uid=user;" & _
          "Pwd=passwo rd"

          Of course, you need to edit "user" and "password"

          -Greg


          On 3/29/05 3:26 AM, in article
          c5100b24cbd74b2 6ab4c260c9d59e7 4a@SQLMonster.c om, "Toby Benjamin via
          SQLMonster.com" <forum@SQLMonst er.com> wrote:
          [color=blue]
          > Hi I tried your code you gave me but got an error.
          >
          > [Microsoft][ODBC Driver Manager] Data source name not found and no default
          > driver specified
          >
          >
          > any ideas?[/color]

          Comment

          Working...