470,616 Members | 2,132 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,616 developers. It's quick & easy.

Sample ASP Script??

Hello,

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

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

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

anyone have any scripts?

--
Message posted via http://www.sqlmonster.com
Jul 23 '05 #1
4 1306
Hi

Check out:
http://www.aspfaq.com/show.asp?id=2351

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

John

"Chad Benjamin via SQLMonster.com" <fo***@SQLMonster.com> wrote in message
news:96******************************@SQLMonster.c om...
Hello,

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

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

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

anyone have any scripts?

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

Jul 23 '05 #2
You really want to use DSN-less connections. Your code will be portable.

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

<%
dim cn
set cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString = "DSN=mail.dsn"
cn.Open
if cn.State <> 1 then
Response.Write "Could not connect to database"
else
Response.Write "Connected!!"
end if
cn.Close
set cn = nothing
%>
On 3/28/05 2:02 PM, in article
96******************************@SQLMonster.com, "Chad Benjamin via
SQLMonster.com" <fo***@SQLMonster.com> wrote:
Hello,

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

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

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

anyone have any scripts?


Jul 23 '05 #3
Hi I tried your code you gave me but got an error.

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

--
Message posted via http://www.sqlmonster.com
Jul 23 '05 #4
That code was for a File DSN. You would need to change the code to include
the full path to the file.

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

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

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

-Greg
On 3/29/05 3:26 AM, in article
c5******************************@SQLMonster.com, "Toby Benjamin via
SQLMonster.com" <fo***@SQLMonster.com> wrote:
Hi I tried your code you gave me but got an error.

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


Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jean Stax | last post: by
reply views Thread by Subrahmanyam Arya | last post: by
4 posts views Thread by Tim Morrison | last post: by
3 posts views Thread by John MacIntyre | last post: by
8 posts views Thread by siol | last post: by
2 posts views Thread by mirandacascade | last post: by
5 posts views Thread by Otto Wyss | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.