Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Using dsn connection in asp include files

New Here ,
May 20, 2011 May 20, 2011

Hi all,

I am having some troubles using the dsn connection I have made and tested successfully in DW.  I followed the guidance to create a dsn but I have created an include file to make this connection for the pages in use.  However I get an error message '80004005' when I go to make the connection using the include file.

Include file

<%

Set conn=Server.CreateObject("ADODB.Connection")

conn.Open "dsn=dsnConn;"

Sub closeconn()

conn.Close

Set conn=Nothing

End Sub

%>

in another asp page I call this include file and want to use the connection to access the database table

SQL="SELECT * FROM Authors"

Set SQLIO = conn.Execute(SQL)

......

As I said earlier, the dsn is set up and is the test works.  I tried doing a similar thing with the .asp file created by DW when I made the dsn connection but am unsure how I can reference and use this is the same way as I could as the variable conn in the include file as this only provides the dsn string.  Below is the contents of the file created by DW on connection of the dsn.

<%

' Filename="Connection_odbc_conn_dsn.htm"

' Type="ADO"

' DesigntimeType="ADO"

' HTTP="false"

' Catalog=""

' Schema=""

Dim dsnConn_STRING

MM dsnConn_STRING = "dsn=dsnSQL;"

%>

Any help or if you require additional information it would be greatly appreciated.

TOPICS
Server side applications
649
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 20, 2011 May 20, 2011

Your DSN's in the two examples you provided are not the same:  dsnConn vs dsnSQL.

I'm not sure why you want to create your own include file rather than just using the DW connection file. I would also advise against opening the connection in the include file. Just use it to store the connection string.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2011 May 20, 2011

Thanks for the update.  You know when you look at something long enough you miss the obvious.  Just one more

thing.  How would I store the connection string in the include file?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 20, 2011 May 20, 2011
LATEST

>How would I store the connection string in the include file?

DW does this for you when you create a connection. The connection file it creates IS an include file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines