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.CreateObject("ADODB.Connection")
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=localhost;" & _
"Port=0; Option=0;" & _
"Socket=/home/greyso2/greysonproperties.com/" & _
".database/mysql/mysql.sock;" & _
"DATABASE=greyso2_Greyson;UID=greyso2; PWD=kramer;"
response.write "<BR>localstr 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=localhost; Port=0; Option=0;
Socket=/home/greyso2/greysonproperties.com/.database/mysql/mysql.sock;
DATABASE=greyso2_Greyson;UID=greyso2; PWD=kramer;
constr failure:
....empty connection string...
localstr contains:
Driver={MySQL}; SERVER=localhost; Port=0; Option=0;
Socket=/home/greyso2/greysonproperties.com/.database/mysql/mysql.sock;
DATABASE=greyso2_Greyson;UID=greyso2; 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:
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]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl... 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.CreateObject("ADODB.Connection")
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=localhost; Port=0; Option=0;
Socket=/home/greyso2/greysonproperties.com/.database/mysql/mysql.sock;
DATABASE=greyso2_Greyson;UID=greyso2; PWD=kramer;"
%>
Here's the code for the asp page that includes this file:
<!--#include virtual="/db.asp"-->
<%
set conn = server.CreateObject("ADODB.Connection")
conn.Open constr
%>
THanks again
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:e$*************@TK2MSFTNGP12.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(connectionstring) 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"
--
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"