473,237 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

empty connection string

AMC
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
Jul 19 '05 #1
17 3204
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"
Jul 19 '05 #2
AMC
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"

Jul 19 '05 #3
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"
Jul 19 '05 #4
AMC
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"

Jul 19 '05 #5
"AMC" wrote in message news:OD**************@TK2MSFTNGP09.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=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
: %>

In this line:
Socket=/home/greyso2/greysonproperties.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
Jul 19 '05 #6
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"
Jul 19 '05 #7
AMC
That is correct, here is what I got when I rant the exact code you posted
below:

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;"
Empty connection string from include file

localstr contains:Driver={MySQL}; SERVER=localhost;Port=0;
Option=0;Socket=/home/greyso2/greysonproperties.com/.database/mysql/mysql.so
ck;DATABASE=greyso2_Greyson;UID=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]" <re******@NOyahoo.SPAMcom> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
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"

Jul 19 '05 #8
AMC
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]" <re******@NOyahoo.SPAMcom> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
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"

Jul 19 '05 #9
AMC
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]" <re******@NOyahoo.SPAMcom> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
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"

Jul 19 '05 #10
AMC
Yes, I'm sure this is correct

"Roland Hall" <nobody@nowhere> wrote in message
news:eH**************@TK2MSFTNGP11.phx.gbl...
"AMC" wrote in message news:OD**************@TK2MSFTNGP09.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=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
: %>

In this line:
Socket=/home/greyso2/greysonproperties.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

Jul 19 '05 #11
"AMC" wrote in message news:e8**************@tk2msftngp13.phx.gbl...
: Yes, I'm sure this is correct

You are attempting to use ODBC. You should use OLE DB.
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;"


An OLE DB connection for mySQL:
"Provider=MySQLProv;Data Source=mydb;User Id=myuserid;Password=mypassword;"

http://dev.mysql.com/doc/connector/odbc/en/manual.html
http://able-consulting.com/MDAC/ADO/...oviderForMySQL
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 - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #12
AMC wrote:
That is correct, here is what I got when I rant the exact code you
posted below:

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;"
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:
Empty connection string from include file
So this verifies that the constr variable does not have a value at this
point.

I'll add option explicit to the include file.


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"
Jul 19 '05 #13
AMC wrote:
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.


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"
Jul 19 '05 #14
AMC
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:Oi**************@TK2MSFTNGP10.phx.gbl...
"AMC" wrote in message news:e8**************@tk2msftngp13.phx.gbl...
: Yes, I'm sure this is correct

You are attempting to use ODBC. You should use OLE DB.
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;"
An OLE DB connection for mySQL:
"Provider=MySQLProv;Data Source=mydb;User

Id=myuserid;Password=mypassword;"
http://dev.mysql.com/doc/connector/odbc/en/manual.html
http://able-consulting.com/MDAC/ADO/...oviderForMySQL 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 - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 19 '05 #15
AMC
Thanks Bob, I'll try this next

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eq*************@TK2MSFTNGP09.phx.gbl...
AMC wrote:
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.


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"

Jul 19 '05 #16
AMC
Okay, this is the code now in the include file:

<%

option explicit

dim constr

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;"

response.write(constr)
%>

When I ran the page the string was written to the page, but I am still
getting the same error in the page that includes the file. Thanks for your
help.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eq*************@TK2MSFTNGP09.phx.gbl...
AMC wrote:
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.


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"

Jul 19 '05 #17
AMC
I take that back. It looks like adding option explicit did the trick after
all.
Thanks again!
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eq*************@TK2MSFTNGP09.phx.gbl...
AMC wrote:
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.


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"

Jul 19 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
2
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, This looks like a long mail, but at the end of this post is my socket wrapper attached. I want to make a timeout procedure that starts counting down after the...
22
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty...
1
by: dave | last post by:
I am having a problem i bleieve a number of other individuals have had before. I have tried the solutions found on the net however I still have the problem. I am hosting a web site on an...
0
by: kevin | last post by:
using vs 2003 the csv file has every field value enclosed in double quotes: i.e. no null values Whe using OleDbDataAdapter to read a csv file (I do create the schema.ini file defining all...
6
by: Vinit | last post by:
Hi I am passing an arraylist to a c#/.net webmethod from a perl client using soap:lite. The trace shows the elements in the xml request. The arraylist input in the webmethod however does not...
26
by: Neville Lang | last post by:
Hi all, I am having a memory blank at the moment. I have been writing in C# for a number of years and now need to do something in VB.NET, so forgive me such a primitive question. In C#, I...
1
by: =?Utf-8?B?RG9u?= | last post by:
Hello, I'm creating a web service that will allow people to enter their contact information into a SQL Server table. I get it to work when I enter all of the fields and press the invoke button,...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.