Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 connecting to SQL Server in ASP

Author  Topic 

whitmarshdaniel
Starting Member

5 Posts

Posted - 2003-11-27 : 06:05:54
I have set up my sql server just to run from my local machine and when i connect to sql query analyser the sql server is local and use windows authentication.

Then i try and access the page through a asp page it asks for a user Id ok so I set one up and with sql analyser and the asp get the error

User not trusted to a sql connection????

Any Ideas?


dbmssql.asp



<%
strConnectsql7 = "Provider=SQLOLEDB; Persist Security Info=False;" & _
"User ID='localhost';Initial Catalog=master;" & _
"Initial File Name=F:\Program Files\Microsoft SQL Server\MSSQL\Data\Master.mdf"
%>

Also tried without user id and receive

Microsoft OLE DB Provider for SQL Server (0x80004005)
Login failed for user 'localhost'. Reason: Not associated with a trusted SQL Server connection.
/datatest/testing.asp, line 15


------------------------------------------------------------------
test.asp


<!-- #include file="../dbconnection/dbmssql.asp" -->
<%


dim strConnectsql7
dim rsSql
dim strSql


set rsSql= Server.CreateObject("ADODB.Recordset")

'strSql= "select * from Willen"


rsSql.Open "Willen", strConnectsql7 , adOpenForwardOnly, adLockOptimistic




'response.write(rsSql("Cust_Name"))
%>

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-11-27 : 06:43:54
It looks to me like you have your connection string ALL wrong. In SQL Server you don't reference the physical file, leave that to access.

Try something like this :

Provider=SQLOLEDB; Data Source=YourServername; Inital Catalog=YourDatabase; User ID=YourUser; Password=YourPassword



Damian
Go to Top of Page
   

- Advertisement -