Click to See Complete Forum and Search --> : Error in connecting to sql server 2000 using asp


method
03-07-2005, 12:14 PM
Hi guys i am new to world of asp . i have a simple script that needs to connect to sql server 2000 northwind db . I am running sql server on windows xp pro sp2 but each time when i run it i get connection errors!!
---------------------------------------------------------------------
script that want to run:
<%

Dim conn

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

conn.Open "Provider=SQLOLEDB; Data Source =(local); Initial Catalog = Northwind; User Id =; Password="

If conn.errors.count = 0 Then

Response.Write "Connected OK"

End If

%>

---------------------------------------------------------------------
error i get :
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80004005)
Invalid authorization specification
/connect.asp, line 7

---------------------------------------------------------------------The above asp script is the one i have problem running .i do not know what should i put for its parameters based on my installation method!!i tried all sort of paramaters and non worked i be happy if some one help me run this on my system..Thanks
---------------------------------------------------------------------the way i log to sql server using sql server service manager is by typing in LAPTOP in the server edit box and and pressing start!

The way i connect to query analyzer i type LAPTOP in sql server edit box and user windows authenticatin and login and pass are empty
---------------------------------------------------------------------here is is how i installed my sql server 2000:

1)put the cd
2)Accept the terms
3) DBMS SELETION: Microsoft sql server 2000 enterprise edition and next
4)LAPTOP in edit box by default can not change it
lOCAL COMPUTERS >>> next
5)Installation option:
create a new instance of sql server or install client tools
6)Name : me
company : me
7)You can select one of the following types of installtions:
server and clietn tools
8)Instance name window : i did not change any thing and i put it as Default and next
9)click the type of setup you prefer. then click next: typical

10) Service account windows:

i changed the deafult user name to sa from Admin007 and domain from laptop to local
then i slected the user the local system account and next.
User the same ac**** for each service .
auto start sql server service

11)in Authentication mode . i did not change any thing and i put windwos auhentication
mode selected.password edit box empty and next

END OF INSTALLATIN!
---------------------------------------------------------------------

lmf232s
03-07-2005, 01:09 PM
Did you install sql server on a server or on your laptop?

If its your laptop, i have to ask if you installed the right sql server.

There are 2 sql server applications, 1 that runs on a server and then 1 that you can run on your local machine.

If you install the first on a local machine it will not run(from my understanding). You need to install sql server 2000 personal edition if you are running it local.

Ill stop there, if you did install the personall edition on a local machine then i will comment more, Let me know, if you installed the server version on your local machine, then i do believe that you will need to get the personal edition in order to use it on your local machine.

method
03-07-2005, 01:17 PM
Originally posted by lmf232s
Did you install sql server on a server or on your laptop?

If its your laptop, i have to ask if you installed the right sql server.

There are 2 sql server applications, 1 that runs on a server and then 1 that you can run on your local machine.

If you install the first on a local machine it will not run(from my understanding). You need to install sql server 2000 personal edition if you are running it local.

Ill stop there, if you did install the personall edition on a local machine then i will comment more, Let me know, if you installed the server version on your local machine, then i do believe that you will need to get the personal edition in order to use it on your local machine.

Many thanks for u reply. I am using sql server that came with my book called SQL second edition the complete refrence. i installed it in my laptop . I am trying to learn how to connect to sql server 2000 using asp. How i know which version i got ? i also installed the sp3 for my sql server! but still does not work!Looking forward for u reply mate.:-)))

lmf232s
03-08-2005, 10:49 AM
If it came with a book then i would assume it was ment to run locally and it should be ok.

try this,

strConnection = "Provider=sqloledb;Data Source=local;Initial Catalog=Northwind;USER ID=?;PASSWORD=?;"
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnection
Set objRS = Server.CreateObject("ADODB.Recordset")

for the user id and password you need those to be correct.

If you forgot your userid and password, create a new login.
Put those into the correct places above.

Then once you have that test it like this

strConnection = "Provider=sqloledb;Data Source=local;Initial Catalog=Northwind;USER ID=?;PASSWORD=?;"
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnection
Set objRS = Server.CreateObject("ADODB.Recordset")

SQL = " SELECT * FROM Categories"
objRS.Open SQL, objConn, 3, 3
if objRS.EOF then
response.write " END OF FILE"
else
response.write objRS("CategoryName") & "<BR>"
end if
objRS.close

set objRS = Nothing
objConn.Close
set objConn =Nothing


see if that works any better.

Now i open the recordset like this
objRS.Open SQL, objConn, 3, 3
You might error out on the numbers 3,3 so you may have to change it to this
objRS.Open SQL, objConn, adOpenStatic, adLockOptimistic

or if you want to use numbers like i do, then go to this web site and copy this code into a page in a include folder and name it
adovbs.asp
http://www.asp101.com/articles/john/adovbs/adovbs.inc

then place this at the top of your global.asa file
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"-->

Let me know how it goes