empty connection string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AMC

    empty connection string

    Hi,

    I'm using an include file to store the connection string to a database.
    Whenever I try to reference that string to open a connection in the page
    that includes the file I get the error 'empy connection string' . When I
    write the string to the page using response.write( connectionstrin g) it shows
    up fine. Is the something else that I need to do?

    Thanks


  • Bob Barrows [MVP]

    #2
    Re: empty connection string

    AMC wrote:[color=blue]
    > Hi,
    >
    > I'm using an include file to store the connection string to a
    > database. Whenever I try to reference that string to open a
    > connection in the page that includes the file I get the error 'empy
    > connection string' . When I write the string to the page using
    > response.write( connectionstrin g) it shows up fine. Is the something
    > else that I need to do?
    >
    > Thanks[/color]

    Ah! I see it! the problem is on line 22 - right there at the 15th character!
    Don't you see it?!?

    Oh wait ... neither do I! You neglected to post the code that generated the
    error.

    ;-)

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Comment

    • AMC

      #3
      Re: empty connection string

      Sorry,

      Here is the code for the include file: By the way this connection string
      works fine when used directly from a page rather than referenced from an
      include file.

      <%

      constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
      Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
      DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"

      %>


      Here's the code for the asp page that includes this file:

      <!--#include virtual="/db.asp"-->

      <%
      set conn = server.CreateOb ject("ADODB.Con nection")
      conn.Open constr
      %>


      THanks again
      "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
      news:e$6hw$3PEH A.904@TK2MSFTNG P12.phx.gbl...[color=blue]
      > AMC wrote:[color=green]
      > > Hi,
      > >
      > > I'm using an include file to store the connection string to a
      > > database. Whenever I try to reference that string to open a
      > > connection in the page that includes the file I get the error 'empy
      > > connection string' . When I write the string to the page using
      > > response.write( connectionstrin g) it shows up fine. Is the something
      > > else that I need to do?
      > >
      > > Thanks[/color]
      >
      > Ah! I see it! the problem is on line 22 - right there at the 15th[/color]
      character![color=blue]
      > Don't you see it?!?
      >
      > Oh wait ... neither do I! You neglected to post the code that generated[/color]
      the[color=blue]
      > error.
      >
      > ;-)
      >
      > Bob Barrows
      >
      > --
      > Microsoft MVP - ASP/ASP.NET
      > Please reply to the newsgroup. This email account is my spam trap so I
      > don't check it very often. If you must reply off-line, then remove the
      > "NO SPAM"
      >
      >[/color]


      Comment

      • Bob Barrows [MVP]

        #4
        Re: empty connection string

        Nothing stands out. Time for some debugging:

        <!--#include virtual="/db.asp"-->
        <%
        if len(constr) = 0 then
        response.write "Empty connection string"
        else
        response.write constr
        set conn = server.CreateOb ject("ADODB.Con nection")
        conn.Open constr
        end if
        %>

        Bob Barrows

        AMC wrote:[color=blue]
        > Sorry,
        >
        > Here is the code for the include file: By the way this connection
        > string works fine when used directly from a page rather than
        > referenced from an include file.
        >
        > <%
        >
        > constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
        > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
        > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
        >
        > %>
        >
        >
        > Here's the code for the asp page that includes this file:
        >
        > <!--#include virtual="/db.asp"-->
        >
        > <%
        > set conn = server.CreateOb ject("ADODB.Con nection")
        > conn.Open constr
        > %>
        >
        >
        > THanks again
        > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
        > news:e$6hw$3PEH A.904@TK2MSFTNG P12.phx.gbl...[color=green]
        >> AMC wrote:[color=darkred]
        >>> Hi,
        >>>
        >>> I'm using an include file to store the connection string to a
        >>> database. Whenever I try to reference that string to open a
        >>> connection in the page that includes the file I get the error 'empy
        >>> connection string' . When I write the string to the page using
        >>> response.write( connectionstrin g) it shows up fine. Is the something
        >>> else that I need to do?
        >>>
        >>> Thanks[/color]
        >>
        >> Ah! I see it! the problem is on line 22 - right there at the 15th
        >> character! Don't you see it?!?
        >>
        >> Oh wait ... neither do I! You neglected to post the code that
        >> generated the error.
        >>
        >> ;-)
        >>
        >> Bob Barrows
        >>
        >> --
        >> Microsoft MVP - ASP/ASP.NET
        >> Please reply to the newsgroup. This email account is my spam trap so
        >> I don't check it very often. If you must reply off-line, then remove
        >> the "NO SPAM"[/color][/color]

        --
        Microsoft MVP - ASP/ASP.NET
        Please reply to the newsgroup. This email account is my spam trap so I
        don't check it very often. If you must reply off-line, then remove the
        "NO SPAM"


        Comment

        • AMC

          #5
          Re: empty connection string

          Hi,

          I've already tried this - before I posted, and the connection string was
          written to the page. This is why I'm perplexed as to why I am getting the
          error that declares it empty.

          Thanks

          "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
          news:%23MJz0T4P EHA.624@TK2MSFT NGP11.phx.gbl.. .[color=blue]
          > Nothing stands out. Time for some debugging:
          >
          > <!--#include virtual="/db.asp"-->
          > <%
          > if len(constr) = 0 then
          > response.write "Empty connection string"
          > else
          > response.write constr
          > set conn = server.CreateOb ject("ADODB.Con nection")
          > conn.Open constr
          > end if
          > %>
          >
          > Bob Barrows
          >
          > AMC wrote:[color=green]
          > > Sorry,
          > >
          > > Here is the code for the include file: By the way this connection
          > > string works fine when used directly from a page rather than
          > > referenced from an include file.
          > >
          > > <%
          > >
          > > constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
          > > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
          > > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
          > >
          > > %>
          > >
          > >
          > > Here's the code for the asp page that includes this file:
          > >
          > > <!--#include virtual="/db.asp"-->
          > >
          > > <%
          > > set conn = server.CreateOb ject("ADODB.Con nection")
          > > conn.Open constr
          > > %>
          > >
          > >
          > > THanks again
          > > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
          > > news:e$6hw$3PEH A.904@TK2MSFTNG P12.phx.gbl...[color=darkred]
          > >> AMC wrote:
          > >>> Hi,
          > >>>
          > >>> I'm using an include file to store the connection string to a
          > >>> database. Whenever I try to reference that string to open a
          > >>> connection in the page that includes the file I get the error 'empy
          > >>> connection string' . When I write the string to the page using
          > >>> response.write( connectionstrin g) it shows up fine. Is the something
          > >>> else that I need to do?
          > >>>
          > >>> Thanks
          > >>
          > >> Ah! I see it! the problem is on line 22 - right there at the 15th
          > >> character! Don't you see it?!?
          > >>
          > >> Oh wait ... neither do I! You neglected to post the code that
          > >> generated the error.
          > >>
          > >> ;-)
          > >>
          > >> Bob Barrows
          > >>
          > >> --
          > >> Microsoft MVP - ASP/ASP.NET
          > >> Please reply to the newsgroup. This email account is my spam trap so
          > >> I don't check it very often. If you must reply off-line, then remove
          > >> the "NO SPAM"[/color][/color]
          >
          > --
          > Microsoft MVP - ASP/ASP.NET
          > Please reply to the newsgroup. This email account is my spam trap so I
          > don't check it very often. If you must reply off-line, then remove the
          > "NO SPAM"
          >
          >[/color]


          Comment

          • Roland Hall

            #6
            Re: empty connection string

            "AMC" wrote in message news:OD$RKL4PEH A.3908@TK2MSFTN GP09.phx.gbl...
            : Sorry,
            :
            : Here is the code for the include file: By the way this connection string
            : works fine when used directly from a page rather than referenced from an
            : include file.
            :
            : <%
            :
            : constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
            : Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
            : DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
            :
            : %>
            :
            :
            : Here's the code for the asp page that includes this file:
            :
            : <!--#include virtual="/db.asp"-->
            :
            : <%
            : set conn = server.CreateOb ject("ADODB.Con nection")
            : conn.Open constr
            : %>

            In this line:
            Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
            Is this correct? .database (dot database)?

            --
            Roland Hall
            /* This information is distributed in the hope that it will be useful, but
            without any warranty; without even the implied warranty of merchantability
            or fitness for a particular purpose. */
            Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
            WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
            MSDN Library - http://msdn.microsoft.com/library/default.asp


            Comment

            • Bob Barrows [MVP]

              #7
              Re: empty connection string

              Let me get this straight. You are telling me that if you do this:

              <!--#include virtual="/db.asp"-->
              <%
              dim localstr
              on error resume next
              if len(constr) = 0 then
              response.write "Empty connection string from include file"
              else
              response.write "constr contains:<BR>" & constr & "<BR>"
              set conn = server.CreateOb ject("ADODB.Con nection")
              conn.Open constr
              if err <> 0 then
              response.write "constr failure:<BR>"
              response.write err.description & "<BR><BR>"
              else
              response.write "Successful connection with constr<BR>"
              conn.close
              end if
              end if
              localstr = "Driver={MySQL} ; SERVER=localhos t;" & _
              "Port=0; Option=0;" & _
              "Socket=/home/greyso2/greysonproperti es.com/" & _
              ".database/mysql/mysql.sock;" & _
              "DATABASE=greys o2_Greyson;UID= greyso2; PWD=kramer;"
              response.write "<BR>locals tr contains:<BR>"
              response.write localstr & "<BR>"
              err.clear
              conn.open localstr
              if err <> 0 then
              response.write "localstr failure:<BR>"
              response.write err.description & "<BR><BR>"
              else
              response.write "Successful connection with localstr<BR>"
              conn.close
              end if
              set conn=nothing
              %>

              You get this:

              constr contains:
              Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
              Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
              DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
              constr failure:
              ....empty connection string...

              localstr contains:
              Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
              Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
              DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
              Successful connection with localstr

              Really? Are you sure you've correctly spelled "constr" in your conn.Open
              statement?

              Are you using Option Explicit? If not, you should add that line to your
              db.asp file (it needs to be the first line processed")

              Bob Barrows

              AMC wrote:[color=blue]
              > Hi,
              >
              > I've already tried this - before I posted, and the connection string
              > was written to the page. This is why I'm perplexed as to why I am
              > getting the error that declares it empty.
              >
              > Thanks
              >
              > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
              > news:%23MJz0T4P EHA.624@TK2MSFT NGP11.phx.gbl.. .[color=green]
              >> Nothing stands out. Time for some debugging:
              >>
              >> <!--#include virtual="/db.asp"-->
              >> <%
              >> if len(constr) = 0 then
              >> response.write "Empty connection string"
              >> else
              >> response.write constr
              >> set conn = server.CreateOb ject("ADODB.Con nection")
              >> conn.Open constr
              >> end if
              >> %>
              >>
              >> Bob Barrows
              >>
              >> AMC wrote:[color=darkred]
              >>> Sorry,
              >>>
              >>> Here is the code for the include file: By the way this connection
              >>> string works fine when used directly from a page rather than
              >>> referenced from an include file.
              >>>
              >>> <%
              >>>
              >>> constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
              >>> Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
              >>> DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
              >>>
              >>> %>
              >>>
              >>>
              >>> Here's the code for the asp page that includes this file:
              >>>
              >>> <!--#include virtual="/db.asp"-->
              >>>
              >>> <%
              >>> set conn = server.CreateOb ject("ADODB.Con nection")
              >>> conn.Open constr
              >>> %>
              >>>
              >>>
              >>> THanks again
              >>> "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
              >>> news:e$6hw$3PEH A.904@TK2MSFTNG P12.phx.gbl...
              >>>> AMC wrote:
              >>>>> Hi,
              >>>>>
              >>>>> I'm using an include file to store the connection string to a
              >>>>> database. Whenever I try to reference that string to open a
              >>>>> connection in the page that includes the file I get the error
              >>>>> 'empy connection string' . When I write the string to the page
              >>>>> using response.write( connectionstrin g) it shows up fine. Is the
              >>>>> something else that I need to do?
              >>>>>
              >>>>> Thanks
              >>>>
              >>>> Ah! I see it! the problem is on line 22 - right there at the 15th
              >>>> character! Don't you see it?!?
              >>>>
              >>>> Oh wait ... neither do I! You neglected to post the code that
              >>>> generated the error.
              >>>>
              >>>> ;-)
              >>>>
              >>>> Bob Barrows
              >>>>
              >>>> --
              >>>> Microsoft MVP - ASP/ASP.NET
              >>>> Please reply to the newsgroup. This email account is my spam trap
              >>>> so I don't check it very often. If you must reply off-line, then
              >>>> remove the "NO SPAM"[/color]
              >>
              >> --
              >> Microsoft MVP - ASP/ASP.NET
              >> Please reply to the newsgroup. This email account is my spam trap so
              >> I don't check it very often. If you must reply off-line, then remove
              >> the "NO SPAM"[/color][/color]

              --
              Microsoft MVP - ASP/ASP.NET
              Please reply to the newsgroup. This email account is my spam trap so I
              don't check it very often. If you must reply off-line, then remove the
              "NO SPAM"


              Comment

              • AMC

                #8
                Re: empty connection string

                That is correct, here is what I got when I rant the exact code you posted
                below:

                constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
                Empty connection string from include file

                localstr contains:Driver ={MySQL}; SERVER=localhos t;Port=0;
                Option=0;Socket =/home/greyso2/greysonproperti es.com/.database/mysql/mysql.so
                ck;DATABASE=gre yso2_Greyson;UI D=greyso2; PWD=kramer;
                Successful connection with localstr

                I'll add option explicit to the include file. And yes I am spelling constr
                correctly

                Thanks



                "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                news:O3TXBM$PEH A.2404@TK2MSFTN GP12.phx.gbl...[color=blue]
                > Let me get this straight. You are telling me that if you do this:
                >
                > <!--#include virtual="/db.asp"-->
                > <%
                > dim localstr
                > on error resume next
                > if len(constr) = 0 then
                > response.write "Empty connection string from include file"
                > else
                > response.write "constr contains:<BR>" & constr & "<BR>"
                > set conn = server.CreateOb ject("ADODB.Con nection")
                > conn.Open constr
                > if err <> 0 then
                > response.write "constr failure:<BR>"
                > response.write err.description & "<BR><BR>"
                > else
                > response.write "Successful connection with constr<BR>"
                > conn.close
                > end if
                > end if
                > localstr = "Driver={MySQL} ; SERVER=localhos t;" & _
                > "Port=0; Option=0;" & _
                > "Socket=/home/greyso2/greysonproperti es.com/" & _
                > ".database/mysql/mysql.sock;" & _
                > "DATABASE=greys o2_Greyson;UID= greyso2; PWD=kramer;"
                > response.write "<BR>locals tr contains:<BR>"
                > response.write localstr & "<BR>"
                > err.clear
                > conn.open localstr
                > if err <> 0 then
                > response.write "localstr failure:<BR>"
                > response.write err.description & "<BR><BR>"
                > else
                > response.write "Successful connection with localstr<BR>"
                > conn.close
                > end if
                > set conn=nothing
                > %>
                >
                > You get this:
                >
                > constr contains:
                > Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
                > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
                > constr failure:
                > ...empty connection string...
                >
                > localstr contains:
                > Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
                > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
                > Successful connection with localstr
                >
                > Really? Are you sure you've correctly spelled "constr" in your conn.Open
                > statement?
                >
                > Are you using Option Explicit? If not, you should add that line to your
                > db.asp file (it needs to be the first line processed")
                >
                > Bob Barrows
                >
                > AMC wrote:[color=green]
                > > Hi,
                > >
                > > I've already tried this - before I posted, and the connection string
                > > was written to the page. This is why I'm perplexed as to why I am
                > > getting the error that declares it empty.
                > >
                > > Thanks
                > >
                > > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                > > news:%23MJz0T4P EHA.624@TK2MSFT NGP11.phx.gbl.. .[color=darkred]
                > >> Nothing stands out. Time for some debugging:
                > >>
                > >> <!--#include virtual="/db.asp"-->
                > >> <%
                > >> if len(constr) = 0 then
                > >> response.write "Empty connection string"
                > >> else
                > >> response.write constr
                > >> set conn = server.CreateOb ject("ADODB.Con nection")
                > >> conn.Open constr
                > >> end if
                > >> %>
                > >>
                > >> Bob Barrows
                > >>
                > >> AMC wrote:
                > >>> Sorry,
                > >>>
                > >>> Here is the code for the include file: By the way this connection
                > >>> string works fine when used directly from a page rather than
                > >>> referenced from an include file.
                > >>>
                > >>> <%
                > >>>
                > >>> constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                > >>> Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                > >>> DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
                > >>>
                > >>> %>
                > >>>
                > >>>
                > >>> Here's the code for the asp page that includes this file:
                > >>>
                > >>> <!--#include virtual="/db.asp"-->
                > >>>
                > >>> <%
                > >>> set conn = server.CreateOb ject("ADODB.Con nection")
                > >>> conn.Open constr
                > >>> %>
                > >>>
                > >>>
                > >>> THanks again
                > >>> "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                > >>> news:e$6hw$3PEH A.904@TK2MSFTNG P12.phx.gbl...
                > >>>> AMC wrote:
                > >>>>> Hi,
                > >>>>>
                > >>>>> I'm using an include file to store the connection string to a
                > >>>>> database. Whenever I try to reference that string to open a
                > >>>>> connection in the page that includes the file I get the error
                > >>>>> 'empy connection string' . When I write the string to the page
                > >>>>> using response.write( connectionstrin g) it shows up fine. Is the
                > >>>>> something else that I need to do?
                > >>>>>
                > >>>>> Thanks
                > >>>>
                > >>>> Ah! I see it! the problem is on line 22 - right there at the 15th
                > >>>> character! Don't you see it?!?
                > >>>>
                > >>>> Oh wait ... neither do I! You neglected to post the code that
                > >>>> generated the error.
                > >>>>
                > >>>> ;-)
                > >>>>
                > >>>> Bob Barrows
                > >>>>
                > >>>> --
                > >>>> Microsoft MVP - ASP/ASP.NET
                > >>>> Please reply to the newsgroup. This email account is my spam trap
                > >>>> so I don't check it very often. If you must reply off-line, then
                > >>>> remove the "NO SPAM"
                > >>
                > >> --
                > >> Microsoft MVP - ASP/ASP.NET
                > >> Please reply to the newsgroup. This email account is my spam trap so
                > >> I don't check it very often. If you must reply off-line, then remove
                > >> the "NO SPAM"[/color][/color]
                >
                > --
                > Microsoft MVP - ASP/ASP.NET
                > Please reply to the newsgroup. This email account is my spam trap so I
                > don't check it very often. If you must reply off-line, then remove the
                > "NO SPAM"
                >
                >[/color]


                Comment

                • AMC

                  #9
                  Re: empty connection string

                  I added option explicit, but still have the same problem. Any additional
                  help would be appreciated. I really don't want to have to set the connection
                  string in every page that access the db.

                  Thanks again

                  "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                  news:O3TXBM$PEH A.2404@TK2MSFTN GP12.phx.gbl...[color=blue]
                  > Let me get this straight. You are telling me that if you do this:
                  >
                  > <!--#include virtual="/db.asp"-->
                  > <%
                  > dim localstr
                  > on error resume next
                  > if len(constr) = 0 then
                  > response.write "Empty connection string from include file"
                  > else
                  > response.write "constr contains:<BR>" & constr & "<BR>"
                  > set conn = server.CreateOb ject("ADODB.Con nection")
                  > conn.Open constr
                  > if err <> 0 then
                  > response.write "constr failure:<BR>"
                  > response.write err.description & "<BR><BR>"
                  > else
                  > response.write "Successful connection with constr<BR>"
                  > conn.close
                  > end if
                  > end if
                  > localstr = "Driver={MySQL} ; SERVER=localhos t;" & _
                  > "Port=0; Option=0;" & _
                  > "Socket=/home/greyso2/greysonproperti es.com/" & _
                  > ".database/mysql/mysql.sock;" & _
                  > "DATABASE=greys o2_Greyson;UID= greyso2; PWD=kramer;"
                  > response.write "<BR>locals tr contains:<BR>"
                  > response.write localstr & "<BR>"
                  > err.clear
                  > conn.open localstr
                  > if err <> 0 then
                  > response.write "localstr failure:<BR>"
                  > response.write err.description & "<BR><BR>"
                  > else
                  > response.write "Successful connection with localstr<BR>"
                  > conn.close
                  > end if
                  > set conn=nothing
                  > %>
                  >
                  > You get this:
                  >
                  > constr contains:
                  > Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
                  > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                  > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
                  > constr failure:
                  > ...empty connection string...
                  >
                  > localstr contains:
                  > Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
                  > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                  > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
                  > Successful connection with localstr
                  >
                  > Really? Are you sure you've correctly spelled "constr" in your conn.Open
                  > statement?
                  >
                  > Are you using Option Explicit? If not, you should add that line to your
                  > db.asp file (it needs to be the first line processed")
                  >
                  > Bob Barrows
                  >
                  > AMC wrote:[color=green]
                  > > Hi,
                  > >
                  > > I've already tried this - before I posted, and the connection string
                  > > was written to the page. This is why I'm perplexed as to why I am
                  > > getting the error that declares it empty.
                  > >
                  > > Thanks
                  > >
                  > > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                  > > news:%23MJz0T4P EHA.624@TK2MSFT NGP11.phx.gbl.. .[color=darkred]
                  > >> Nothing stands out. Time for some debugging:
                  > >>
                  > >> <!--#include virtual="/db.asp"-->
                  > >> <%
                  > >> if len(constr) = 0 then
                  > >> response.write "Empty connection string"
                  > >> else
                  > >> response.write constr
                  > >> set conn = server.CreateOb ject("ADODB.Con nection")
                  > >> conn.Open constr
                  > >> end if
                  > >> %>
                  > >>
                  > >> Bob Barrows
                  > >>
                  > >> AMC wrote:
                  > >>> Sorry,
                  > >>>
                  > >>> Here is the code for the include file: By the way this connection
                  > >>> string works fine when used directly from a page rather than
                  > >>> referenced from an include file.
                  > >>>
                  > >>> <%
                  > >>>
                  > >>> constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                  > >>> Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                  > >>> DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
                  > >>>
                  > >>> %>
                  > >>>
                  > >>>
                  > >>> Here's the code for the asp page that includes this file:
                  > >>>
                  > >>> <!--#include virtual="/db.asp"-->
                  > >>>
                  > >>> <%
                  > >>> set conn = server.CreateOb ject("ADODB.Con nection")
                  > >>> conn.Open constr
                  > >>> %>
                  > >>>
                  > >>>
                  > >>> THanks again
                  > >>> "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                  > >>> news:e$6hw$3PEH A.904@TK2MSFTNG P12.phx.gbl...
                  > >>>> AMC wrote:
                  > >>>>> Hi,
                  > >>>>>
                  > >>>>> I'm using an include file to store the connection string to a
                  > >>>>> database. Whenever I try to reference that string to open a
                  > >>>>> connection in the page that includes the file I get the error
                  > >>>>> 'empy connection string' . When I write the string to the page
                  > >>>>> using response.write( connectionstrin g) it shows up fine. Is the
                  > >>>>> something else that I need to do?
                  > >>>>>
                  > >>>>> Thanks
                  > >>>>
                  > >>>> Ah! I see it! the problem is on line 22 - right there at the 15th
                  > >>>> character! Don't you see it?!?
                  > >>>>
                  > >>>> Oh wait ... neither do I! You neglected to post the code that
                  > >>>> generated the error.
                  > >>>>
                  > >>>> ;-)
                  > >>>>
                  > >>>> Bob Barrows
                  > >>>>
                  > >>>> --
                  > >>>> Microsoft MVP - ASP/ASP.NET
                  > >>>> Please reply to the newsgroup. This email account is my spam trap
                  > >>>> so I don't check it very often. If you must reply off-line, then
                  > >>>> remove the "NO SPAM"
                  > >>
                  > >> --
                  > >> Microsoft MVP - ASP/ASP.NET
                  > >> Please reply to the newsgroup. This email account is my spam trap so
                  > >> I don't check it very often. If you must reply off-line, then remove
                  > >> the "NO SPAM"[/color][/color]
                  >
                  > --
                  > Microsoft MVP - ASP/ASP.NET
                  > Please reply to the newsgroup. This email account is my spam trap so I
                  > don't check it very often. If you must reply off-line, then remove the
                  > "NO SPAM"
                  >
                  >[/color]


                  Comment

                  • AMC

                    #10
                    Re: empty connection string

                    Is there anything else I need to add to the include file or specify in the
                    other page to recognize this string? I feel like I'm missing something
                    really simple here.

                    "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                    news:O3TXBM$PEH A.2404@TK2MSFTN GP12.phx.gbl...[color=blue]
                    > Let me get this straight. You are telling me that if you do this:
                    >
                    > <!--#include virtual="/db.asp"-->
                    > <%
                    > dim localstr
                    > on error resume next
                    > if len(constr) = 0 then
                    > response.write "Empty connection string from include file"
                    > else
                    > response.write "constr contains:<BR>" & constr & "<BR>"
                    > set conn = server.CreateOb ject("ADODB.Con nection")
                    > conn.Open constr
                    > if err <> 0 then
                    > response.write "constr failure:<BR>"
                    > response.write err.description & "<BR><BR>"
                    > else
                    > response.write "Successful connection with constr<BR>"
                    > conn.close
                    > end if
                    > end if
                    > localstr = "Driver={MySQL} ; SERVER=localhos t;" & _
                    > "Port=0; Option=0;" & _
                    > "Socket=/home/greyso2/greysonproperti es.com/" & _
                    > ".database/mysql/mysql.sock;" & _
                    > "DATABASE=greys o2_Greyson;UID= greyso2; PWD=kramer;"
                    > response.write "<BR>locals tr contains:<BR>"
                    > response.write localstr & "<BR>"
                    > err.clear
                    > conn.open localstr
                    > if err <> 0 then
                    > response.write "localstr failure:<BR>"
                    > response.write err.description & "<BR><BR>"
                    > else
                    > response.write "Successful connection with localstr<BR>"
                    > conn.close
                    > end if
                    > set conn=nothing
                    > %>
                    >
                    > You get this:
                    >
                    > constr contains:
                    > Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
                    > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                    > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
                    > constr failure:
                    > ...empty connection string...
                    >
                    > localstr contains:
                    > Driver={MySQL}; SERVER=localhos t; Port=0; Option=0;
                    > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                    > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;
                    > Successful connection with localstr
                    >
                    > Really? Are you sure you've correctly spelled "constr" in your conn.Open
                    > statement?
                    >
                    > Are you using Option Explicit? If not, you should add that line to your
                    > db.asp file (it needs to be the first line processed")
                    >
                    > Bob Barrows
                    >
                    > AMC wrote:[color=green]
                    > > Hi,
                    > >
                    > > I've already tried this - before I posted, and the connection string
                    > > was written to the page. This is why I'm perplexed as to why I am
                    > > getting the error that declares it empty.
                    > >
                    > > Thanks
                    > >
                    > > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                    > > news:%23MJz0T4P EHA.624@TK2MSFT NGP11.phx.gbl.. .[color=darkred]
                    > >> Nothing stands out. Time for some debugging:
                    > >>
                    > >> <!--#include virtual="/db.asp"-->
                    > >> <%
                    > >> if len(constr) = 0 then
                    > >> response.write "Empty connection string"
                    > >> else
                    > >> response.write constr
                    > >> set conn = server.CreateOb ject("ADODB.Con nection")
                    > >> conn.Open constr
                    > >> end if
                    > >> %>
                    > >>
                    > >> Bob Barrows
                    > >>
                    > >> AMC wrote:
                    > >>> Sorry,
                    > >>>
                    > >>> Here is the code for the include file: By the way this connection
                    > >>> string works fine when used directly from a page rather than
                    > >>> referenced from an include file.
                    > >>>
                    > >>> <%
                    > >>>
                    > >>> constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                    > >>> Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                    > >>> DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
                    > >>>
                    > >>> %>
                    > >>>
                    > >>>
                    > >>> Here's the code for the asp page that includes this file:
                    > >>>
                    > >>> <!--#include virtual="/db.asp"-->
                    > >>>
                    > >>> <%
                    > >>> set conn = server.CreateOb ject("ADODB.Con nection")
                    > >>> conn.Open constr
                    > >>> %>
                    > >>>
                    > >>>
                    > >>> THanks again
                    > >>> "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
                    > >>> news:e$6hw$3PEH A.904@TK2MSFTNG P12.phx.gbl...
                    > >>>> AMC wrote:
                    > >>>>> Hi,
                    > >>>>>
                    > >>>>> I'm using an include file to store the connection string to a
                    > >>>>> database. Whenever I try to reference that string to open a
                    > >>>>> connection in the page that includes the file I get the error
                    > >>>>> 'empy connection string' . When I write the string to the page
                    > >>>>> using response.write( connectionstrin g) it shows up fine. Is the
                    > >>>>> something else that I need to do?
                    > >>>>>
                    > >>>>> Thanks
                    > >>>>
                    > >>>> Ah! I see it! the problem is on line 22 - right there at the 15th
                    > >>>> character! Don't you see it?!?
                    > >>>>
                    > >>>> Oh wait ... neither do I! You neglected to post the code that
                    > >>>> generated the error.
                    > >>>>
                    > >>>> ;-)
                    > >>>>
                    > >>>> Bob Barrows
                    > >>>>
                    > >>>> --
                    > >>>> Microsoft MVP - ASP/ASP.NET
                    > >>>> Please reply to the newsgroup. This email account is my spam trap
                    > >>>> so I don't check it very often. If you must reply off-line, then
                    > >>>> remove the "NO SPAM"
                    > >>
                    > >> --
                    > >> Microsoft MVP - ASP/ASP.NET
                    > >> Please reply to the newsgroup. This email account is my spam trap so
                    > >> I don't check it very often. If you must reply off-line, then remove
                    > >> the "NO SPAM"[/color][/color]
                    >
                    > --
                    > Microsoft MVP - ASP/ASP.NET
                    > Please reply to the newsgroup. This email account is my spam trap so I
                    > don't check it very often. If you must reply off-line, then remove the
                    > "NO SPAM"
                    >
                    >[/color]


                    Comment

                    • AMC

                      #11
                      Re: empty connection string

                      Yes, I'm sure this is correct

                      "Roland Hall" <nobody@nowhere > wrote in message
                      news:eHixof8PEH A.3420@TK2MSFTN GP11.phx.gbl...[color=blue]
                      > "AMC" wrote in message news:OD$RKL4PEH A.3908@TK2MSFTN GP09.phx.gbl...
                      > : Sorry,
                      > :
                      > : Here is the code for the include file: By the way this connection string
                      > : works fine when used directly from a page rather than referenced from an
                      > : include file.
                      > :
                      > : <%
                      > :
                      > : constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                      > : Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                      > : DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"
                      > :
                      > : %>
                      > :
                      > :
                      > : Here's the code for the asp page that includes this file:
                      > :
                      > : <!--#include virtual="/db.asp"-->
                      > :
                      > : <%
                      > : set conn = server.CreateOb ject("ADODB.Con nection")
                      > : conn.Open constr
                      > : %>
                      >
                      > In this line:
                      > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                      > Is this correct? .database (dot database)?
                      >
                      > --
                      > Roland Hall
                      > /* This information is distributed in the hope that it will be useful, but
                      > without any warranty; without even the implied warranty of merchantability
                      > or fitness for a particular purpose. */
                      > Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
                      > WSH 5.6 Documentation -[/color]
                      http://msdn.microsoft.com/downloads/list/webdev.asp[color=blue]
                      > MSDN Library - http://msdn.microsoft.com/library/default.asp
                      >
                      >[/color]


                      Comment

                      • Roland Hall

                        #12
                        Re: empty connection string

                        "AMC" wrote in message news:e8QEiHEQEH A.3944@tk2msftn gp13.phx.gbl...
                        : Yes, I'm sure this is correct

                        You are attempting to use ODBC. You should use OLE DB.
                        [color=blue]
                        > constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                        > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                        > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"[/color]

                        An OLE DB connection for mySQL:
                        "Provider=MySQL Prov;Data Source=mydb;Use r Id=myuserid;Pas sword=mypasswor d;"



                        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.



                        --
                        Roland Hall
                        /* This information is distributed in the hope that it will be useful, but
                        without any warranty; without even the implied warranty of merchantability
                        or fitness for a particular purpose. */
                        Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
                        WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
                        MSDN Library - http://msdn.microsoft.com/library/default.asp


                        Comment

                        • Bob Barrows [MVP]

                          #13
                          Re: empty connection string

                          AMC wrote:[color=blue]
                          > That is correct, here is what I got when I rant the exact code you
                          > posted below:
                          >
                          > constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                          > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                          > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"[/color]

                          Is this text being written to the browser window? If so, where is it coming
                          from? Is it from a line of code in the include file?

                          The output from the code I posted begins below:
                          [color=blue]
                          > Empty connection string from include file[/color]

                          So this verifies that the constr variable does not have a value at this
                          point.
                          [color=blue]
                          >
                          > I'll add option explicit to the include file.[/color]

                          Bob Barrows
                          --
                          Microsoft MVP - ASP/ASP.NET
                          Please reply to the newsgroup. This email account is my spam trap so I
                          don't check it very often. If you must reply off-line, then remove the
                          "NO SPAM"


                          Comment

                          • Bob Barrows [MVP]

                            #14
                            Re: empty connection string

                            AMC wrote:[color=blue]
                            > I added option explicit, but still have the same problem. Any
                            > additional help would be appreciated. I really don't want to have to
                            > set the connection string in every page that access the db.
                            >[/color]

                            I think the next step is to add:

                            response.write "Within #include file, constr contains:<BR>"
                            response.write """" & constr & """"

                            to the include file to verify that the constr variable contains the
                            connection string. We know that it has no value in the "host" page so we
                            need to look more closely at the include file itself.

                            Bob Barrows
                            --
                            Microsoft MVP - ASP/ASP.NET
                            Please reply to the newsgroup. This email account is my spam trap so I
                            don't check it very often. If you must reply off-line, then remove the
                            "NO SPAM"


                            Comment

                            • AMC

                              #15
                              Re: empty connection string

                              I'm connecting to a MYSQL database. I'm not sure if there is an OLEDB driver
                              for MYSQL, besides, the connection string works fine when used directly in a
                              page, the problem is accessing it from an included file. That is the issue I
                              am trying to address here. I appreciate your help, but please read my posts
                              before replying next time.

                              "Roland Hall" <nobody@nowhere > wrote in message
                              news:OiSbF6KQEH A.1728@TK2MSFTN GP10.phx.gbl...[color=blue]
                              > "AMC" wrote in message news:e8QEiHEQEH A.3944@tk2msftn gp13.phx.gbl...
                              > : Yes, I'm sure this is correct
                              >
                              > You are attempting to use ODBC. You should use OLE DB.
                              >[color=green]
                              > > constr = "Driver={MySQL} ; SERVER=localhos t; Port=0; Option=0;
                              > > Socket=/home/greyso2/greysonproperti es.com/.database/mysql/mysql.sock;
                              > > DATABASE=greyso 2_Greyson;UID=g reyso2; PWD=kramer;"[/color]
                              >
                              > An OLE DB connection for mySQL:
                              > "Provider=MySQL Prov;Data Source=mydb;Use r[/color]
                              Id=myuserid;Pas sword=mypasswor d;"[color=blue]
                              >
                              > http://dev.mysql.com/doc/connector/odbc/en/manual.html
                              >[/color]
                              http://able-consulting.com/MDAC/ADO/...oviderForMySQL[color=blue]
                              > http://www.connectionstrings.com/
                              > http://www.vzio.com/tutorials/mysql_database.asp?page=4
                              >
                              > --
                              > Roland Hall
                              > /* This information is distributed in the hope that it will be useful, but
                              > without any warranty; without even the implied warranty of merchantability
                              > or fitness for a particular purpose. */
                              > Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
                              > WSH 5.6 Documentation -[/color]
                              http://msdn.microsoft.com/downloads/list/webdev.asp[color=blue]
                              > MSDN Library - http://msdn.microsoft.com/library/default.asp
                              >
                              >[/color]


                              Comment

                              Working...