473,395 Members | 1,571 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,395 software developers and data experts.

ASP Access to SQL SERVER change

I have an ASP page that was done in VBScript
It is setup to read an Access database and I need to change it to read
a Sql 2005 Database.

The code that is used to open the Access Database:

Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
Dim strLocation, iLength
strLocation = Request.ServerVariables("PATH_TRANSLATED")
iLength = Len(strLocation)
iLength = iLength - 11
strLocation = Left(strLocation, iLength)
strLocation = strLocation & "../Database.mdb"
adoConnection.Open ("Data Source=" & strLocation)
adoRecordset.ActiveConnection = AdoConnection
In my VB 6.0 app I use the following to open the SQL Database"

Set DataBaseTS_1 = New ADODB.Connection
DataBaseTS_1.ConnectionString ="Provider=MSDASQL.1;Persist Security
Info=False;Extended
Properties=Description=Large Pump Data Source;DRIVER=SQL
Server;SERVER=LPDATASYSTEM\PL3LP;APP=Microsoft Data Access
Components;WSID=LPDATASYSTEM;DATABASE=LargePump;Tr usted_Connection=Yes;Initi
al Catalog=LargePump"

DataBaseTS_1.Open

How can I get the VBScript to open the SQL Database?

Thanks,
Bob Hiller
Lifts for the Disabled LLC


Mar 15 '06 #1
22 3379
Bob and Sharon Hiller wrote:
I have an ASP page that was done in VBScript
It is setup to read an Access database and I need to change it
to read a Sql 2005 Database. <snip> How can I get the VBScript to open the SQL Database?

http://www.aspfaq.com/show.asp?id=2126
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 15 '06 #2
Here is what I have tried: No records are returned(This table has 2094 rows,
28 columns)

Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.ConnectionString = "Provider=MSDASQL.1;" _
& "Persist Security Info=False;" _
& "Extended Properties=Description=Large Pump Data Source;" _
& "DRIVER=SQL Server;SERVER=LPDATASYSTEM\PL3LP;" _
& "APP=Microsoft Data Access Components;" _
& "WSID=LPDATASYSTEM;DATABASE=LargePump;" _
& "Trusted_Connection=Yes;Initial Catalog=LargePump"
adoConnection.Open

adoRecordset.ActiveConnection = adoConnection
Dim SqlSelect
SqlSelect = "select * from [LargePumpFloor_TS1] order by Row_num"
adoRecordset.CursorLocation = 3
adoRecordset.CursorType = 3
call adoRecordset.Open(SQLSelect)
adoRecordset.PageSize = 12
adoRecordset.CacheSize = adoRecordset.PageSize
intPageCount = adoRecordset.PageCount
intRecordCount = adoRecordset.RecordCount

Do you see anything ? I am running IIS on Windows XP Pro with MS
SQL Server 2005. I can access and see any MS Access Database but no SQL
databases.

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
Bob and Sharon Hiller wrote:
I have an ASP page that was done in VBScript
It is setup to read an Access database and I need to change it
to read a Sql 2005 Database.

<snip>
How can I get the VBScript to open the SQL Database?

http://www.aspfaq.com/show.asp?id=2126
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 15 '06 #3
Bob and Sharon Hiller wrote:
Here is what I have tried: No records are returned(This table has
2094 rows, 28 columns)

Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.ConnectionString = "Provider=MSDASQL.1;" _
& "Persist Security Info=False;" _
& "Extended Properties=Description=Large Pump Data Source;" _
& "DRIVER=SQL Server;SERVER=LPDATASYSTEM\PL3LP;" _
& "APP=Microsoft Data Access Components;" _
& "WSID=LPDATASYSTEM;DATABASE=LargePump;" _
& "Trusted_Connection=Yes;Initial Catalog=LargePump"
Nothing to do with your problem, but you should avoid odbc. See the link in
my original reply.
adoConnection.Open

adoRecordset.ActiveConnection = adoConnection
Dim SqlSelect
SqlSelect = "select * from [LargePumpFloor_TS1] order by Row_num"
adoRecordset.CursorLocation = 3
adoRecordset.CursorType = 3
call adoRecordset.Open(SQLSelect)
adoRecordset.PageSize = 12
adoRecordset.CacheSize = adoRecordset.PageSize
intPageCount = adoRecordset.PageCount
intRecordCount = adoRecordset.RecordCount

Do you see anything ? I am running IIS on Windows XP Pro with MS
SQL Server 2005. I can access and see any MS Access Database but no
SQL databases.

I see no attempt to check the recordset's EOF property. How are you
determining that no records were returned?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 15 '06 #4
Bob,
After
intRecordCount = adoRecordset.RecordCount

I have:
If intRecordCount <> 0 Then
Response.Write("Record Count <> 0")
Else
Response.Write("Record Count = 0")
End If

I also tried:
intRowsCount = adoRecordset.GetRows
If intRowsCount <> 0 Then
Response.Write("Rows Count <> 0")
Else
Response.Write("Rows Count = 0")
End If

Looking at the link you sent, it appears that I would need to totally
reconfigure the SQL server to use that method.

Thanks,
Bob Hiller
Lifts for the Disabled LLC

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:ue****************@tk2msftngp13.phx.gbl...
Bob and Sharon Hiller wrote:
Here is what I have tried: No records are returned(This table has
2094 rows, 28 columns)

Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.ConnectionString = "Provider=MSDASQL.1;" _
& "Persist Security Info=False;" _
& "Extended Properties=Description=Large Pump Data Source;" _
& "DRIVER=SQL Server;SERVER=LPDATASYSTEM\PL3LP;" _
& "APP=Microsoft Data Access Components;" _
& "WSID=LPDATASYSTEM;DATABASE=LargePump;" _
& "Trusted_Connection=Yes;Initial Catalog=LargePump"


Nothing to do with your problem, but you should avoid odbc. See the link
in
my original reply.
adoConnection.Open

adoRecordset.ActiveConnection = adoConnection
Dim SqlSelect
SqlSelect = "select * from [LargePumpFloor_TS1] order by Row_num"
adoRecordset.CursorLocation = 3
adoRecordset.CursorType = 3
call adoRecordset.Open(SQLSelect)
adoRecordset.PageSize = 12
adoRecordset.CacheSize = adoRecordset.PageSize
intPageCount = adoRecordset.PageCount
intRecordCount = adoRecordset.RecordCount

Do you see anything ? I am running IIS on Windows XP Pro with MS
SQL Server 2005. I can access and see any MS Access Database but no
SQL databases.

I see no attempt to check the recordset's EOF property. How are you
determining that no records were returned?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 16 '06 #5

Bob and Sharon Hiller wrote:
Bob,
After
intRecordCount = adoRecordset.RecordCount

I have:
If intRecordCount <> 0 Then
Response.Write("Record Count <> 0")
Else
Response.Write("Record Count = 0")
End If

I also tried:
intRowsCount = adoRecordset.GetRows
If intRowsCount <> 0 Then
Response.Write("Rows Count <> 0")
Else
Response.Write("Rows Count = 0")
End If


GetRows returns an array, not a numeric value.

arrRows = adoRecordset.GetRows()
If isarray(arrRows) Then
intRowsCount = ubound(arrRows,2)
response.write "Total Rows = " & intRowsCount +1
Else
response.write "No Records Found
End If

--
Mike Brind

Mar 16 '06 #6

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...

Bob and Sharon Hiller wrote:
Bob,
After
intRecordCount = adoRecordset.RecordCount

I have:
If intRecordCount <> 0 Then
Response.Write("Record Count <> 0")
Else
Response.Write("Record Count = 0")
End If

I also tried:
intRowsCount = adoRecordset.GetRows
If intRowsCount <> 0 Then
Response.Write("Rows Count <> 0")
Else
Response.Write("Rows Count = 0")
End If


GetRows returns an array, not a numeric value.

arrRows = adoRecordset.GetRows()
If isarray(arrRows) Then
intRowsCount = ubound(arrRows,2)
response.write "Total Rows = " & intRowsCount +1
Else
response.write "No Records Found
End If

--
Mike Brind


Problem is GetRows will error if there are no rows. Use:

If not adoRecordset.EOF Then
arrRows = adoRecordset.GetRows()
End If

If isarray(arrRows) Then
intRowsCount = ubound(arrRows,2)
response.write "Total Rows = " & intRowsCount +1
Else
response.write "No Records Found
End

Anthony.
Mar 16 '06 #7
Bob and Sharon Hiller wrote:
Bob,
After
intRecordCount = adoRecordset.RecordCount
With a default server-side, forward-only cursor, Recordcount will always
contain -1.
http://www.aspfaq.com/show.asp?id=2193
As this article says, there are better ways to count the records returned by
a query.

I also tried:
intRowsCount = adoRecordset.GetRows
Mike addressed this one.
Looking at the link you sent, it appears that I would need to totally
reconfigure the SQL server to use that method.


Why? Where does that article say anything about reconfiguring SQL Server if
you don't have to? Simply change your connection string to the one he
suggests using for integrated (Windows) security. Here, let me show you:
Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.ConnectionString = "Provider=MSDASQL.1;" _
& "Persist Security Info=False;" _
& "Extended Properties=Description=Large Pump Data Source;" _
& "DRIVER=SQL Server;SERVER=LPDATASYSTEM\PL3LP;" _
& "APP=Microsoft Data Access Components;" _
& "WSID=LPDATASYSTEM;DATABASE=LargePump;" _
& "Trusted_Connection=Yes;Initial Catalog=LargePump"

adoConnection.ConnectionString = "Provider=SQLOLEDB;" _
& "Persist Security Info=False;" _
& "Data Source=LPDATASYSTEM\PL3LP;" _
& "Application Name=Microsoft Data Access Components;" _
& "Integrated Security=SSP1;Initial Catalog=LargePump"

'I would suggest setting the Application Name to a more specific name rather
than the generic "Microsoft ... ". This will allow debugging using SQL
Profiler to be easier (you can set up a trace using a filter to display only
a specific application).

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 16 '06 #8
I am starting to think that there is no way to connect to SQL 2005 with
VBScript. I have tried 25 different suggestions from news groups and forums
and none have worked. The only thing that seems to work is report services
using .net and we are not going to change every page we have. I think we
will just go back to SQL 2000 where everything worked fine.

Thanks for the help.

Bob Hiller
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:Ob*************@TK2MSFTNGP10.phx.gbl...
Bob and Sharon Hiller wrote:
Bob,
After
intRecordCount = adoRecordset.RecordCount

With a default server-side, forward-only cursor, Recordcount will always
contain -1.
http://www.aspfaq.com/show.asp?id=2193
As this article says, there are better ways to count the records returned
by
a query.

I also tried:
intRowsCount = adoRecordset.GetRows


Mike addressed this one.

Looking at the link you sent, it appears that I would need to totally
reconfigure the SQL server to use that method.


Why? Where does that article say anything about reconfiguring SQL Server
if
you don't have to? Simply change your connection string to the one he
suggests using for integrated (Windows) security. Here, let me show you:
Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.ConnectionString = "Provider=MSDASQL.1;" _
& "Persist Security Info=False;" _
& "Extended Properties=Description=Large Pump Data Source;" _
& "DRIVER=SQL Server;SERVER=LPDATASYSTEM\PL3LP;" _
& "APP=Microsoft Data Access Components;" _
& "WSID=LPDATASYSTEM;DATABASE=LargePump;" _
& "Trusted_Connection=Yes;Initial Catalog=LargePump"

adoConnection.ConnectionString = "Provider=SQLOLEDB;" _
& "Persist Security Info=False;" _
& "Data Source=LPDATASYSTEM\PL3LP;" _
& "Application Name=Microsoft Data Access Components;" _
& "Integrated Security=SSP1;Initial Catalog=LargePump"

'I would suggest setting the Application Name to a more specific name
rather
than the generic "Microsoft ... ". This will allow debugging using SQL
Profiler to be easier (you can set up a trace using a filter to display
only
a specific application).

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 16 '06 #9
Nobody can help you if you just throw up your hands instead of describing
your symptoms.

Bob and Sharon Hiller wrote:
I am starting to think that there is no way to connect to SQL 2005
with VBScript. I have tried 25 different suggestions from news groups
and forums and none have worked. The only thing that seems to work is
report services using .net and we are not going to change every page
we have. I think we will just go back to SQL 2000 where everything
worked fine.

Thanks for the help.

Bob Hiller
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:Ob*************@TK2MSFTNGP10.phx.gbl...
Bob and Sharon Hiller wrote:
Bob,
After
intRecordCount = adoRecordset.RecordCount

With a default server-side, forward-only cursor, Recordcount will
always contain -1.
http://www.aspfaq.com/show.asp?id=2193
As this article says, there are better ways to count the records
returned by
a query.

I also tried:
intRowsCount = adoRecordset.GetRows


Mike addressed this one.

Looking at the link you sent, it appears that I would need to
totally reconfigure the SQL server to use that method.


Why? Where does that article say anything about reconfiguring SQL
Server if
you don't have to? Simply change your connection string to the one he
suggests using for integrated (Windows) security. Here, let me show
you:
> Set adoConnection = server.CreateObject("ADODB.Connection")
> Set adoRecordset = server.CreateObject("ADODB.Recordset")
> adoConnection.ConnectionString = "Provider=MSDASQL.1;" _
> & "Persist Security Info=False;" _
> & "Extended Properties=Description=Large Pump Data Source;" _
> & "DRIVER=SQL Server;SERVER=LPDATASYSTEM\PL3LP;" _
> & "APP=Microsoft Data Access Components;" _
> & "WSID=LPDATASYSTEM;DATABASE=LargePump;" _
> & "Trusted_Connection=Yes;Initial Catalog=LargePump"

adoConnection.ConnectionString = "Provider=SQLOLEDB;" _
& "Persist Security Info=False;" _
& "Data Source=LPDATASYSTEM\PL3LP;" _
& "Application Name=Microsoft Data Access Components;" _
& "Integrated Security=SSP1;Initial Catalog=LargePump"

'I would suggest setting the Application Name to a more specific name
rather
than the generic "Microsoft ... ". This will allow debugging using
SQL Profiler to be easier (you can set up a trace using a filter to
display only
a specific application).

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 16 '06 #10
Bob,
I think I know what may be happening. I believe that you must use a User ID
and Password to connect to the DB in ASP,VBScript. I believe this because
every connection string that uses a trusted connection works fine in VB 6.0.
If I try to use a connection string in VB 6.0 that uses User ID and PassWord
I get the following error:
(Login failed for user '<LoginName>'. Reason: Not associated with a trusted
SQL Server connection)

I have tried every suggestion from MS website on how to setup a User ID and
Password that is associated with a trusted SQL Server connection but cannot
make one work. I have SQL 2005 setup in authentication mode = SQL Server
and Windows

Sincerly,
Bob Hiller
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Nobody can help you if you just throw up your hands instead of describing
your symptoms.

Bob and Sharon Hiller wrote:
I am starting to think that there is no way to connect to SQL 2005
with VBScript. I have tried 25 different suggestions from news groups
and forums and none have worked. The only thing that seems to work is
report services using .net and we are not going to change every page
we have. I think we will just go back to SQL 2000 where everything
worked fine.

Thanks for the help.

Bob Hiller
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:Ob*************@TK2MSFTNGP10.phx.gbl...
Bob and Sharon Hiller wrote:
Bob,
After
intRecordCount = adoRecordset.RecordCount

With a default server-side, forward-only cursor, Recordcount will
always contain -1.
http://www.aspfaq.com/show.asp?id=2193
As this article says, there are better ways to count the records
returned by
a query.
I also tried:
intRowsCount = adoRecordset.GetRows

Mike addressed this one.

Looking at the link you sent, it appears that I would need to
totally reconfigure the SQL server to use that method.

Why? Where does that article say anything about reconfiguring SQL
Server if
you don't have to? Simply change your connection string to the one he
suggests using for integrated (Windows) security. Here, let me show
you:

>> Set adoConnection = server.CreateObject("ADODB.Connection")
>> Set adoRecordset = server.CreateObject("ADODB.Recordset")
>> adoConnection.ConnectionString = "Provider=MSDASQL.1;" _
>> & "Persist Security Info=False;" _
>> & "Extended Properties=Description=Large Pump Data Source;" _
>> & "DRIVER=SQL Server;SERVER=LPDATASYSTEM\PL3LP;" _
>> & "APP=Microsoft Data Access Components;" _
>> & "WSID=LPDATASYSTEM;DATABASE=LargePump;" _
>> & "Trusted_Connection=Yes;Initial Catalog=LargePump"
>
adoConnection.ConnectionString = "Provider=SQLOLEDB;" _
& "Persist Security Info=False;" _
& "Data Source=LPDATASYSTEM\PL3LP;" _
& "Application Name=Microsoft Data Access Components;" _
& "Integrated Security=SSP1;Initial Catalog=LargePump"

'I would suggest setting the Application Name to a more specific name
rather
than the generic "Microsoft ... ". This will allow debugging using
SQL Profiler to be easier (you can set up a trace using a filter to
display only
a specific application).

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 16 '06 #11
Bob and Sharon Hiller wrote:
(Login failed for user '<LoginName>'. Reason: Not associated with a
trusted SQL Server connection)

I have tried every suggestion from MS website on how to setup a User
ID and Password that is associated with a trusted SQL Server
connection but cannot make one work. I have SQL 2005 setup in
authentication mode = SQL Server and Windows


Check out http://www.connectionstrings.com/

In particular, look in the SQL Server (not 2005) "read more" section for
details on forcing a TCP/IP connection.

When I was having similar trouble with some SQL Server 2000 connections,
this resolved it. For some reason, one of our web servers just WANTED to
connect via named pipes. Under Windows 2000, we could address this with a
registry key, but not in Server 2003.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Mar 16 '06 #12
Bob and Sharon Hiller wrote:
Bob,
I think I know what may be happening. I believe that you must use a
User ID and Password to connect to the DB in ASP,VBScript. I believe
this because every connection string that uses a trusted connection
works fine in VB 6.0. If I try to use a connection string in VB 6.0
that uses User ID and PassWord I get the following error:
(Login failed for user '<LoginName>'. Reason: Not associated with a
trusted SQL Server connection)
That's probably because you failed to remove the "Trusted_Connection"
attribute when attempting to connect with user id and password.
I have tried every suggestion from MS website on how to setup a User
ID and Password that is associated with a trusted SQL Server
connection but cannot make one work. I have SQL 2005 setup in
authentication mode = SQL Server and Windows


Having said that, I am having trouble connecting with integrated security
from ASP using either MSDASQL or SQLOLEDB. It seems the Windows credentials
are not being passed correctly. The Event Viewer on my SQL Server has items
containing:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [CLIENT:
xxx.xx.xx.xxx]

So even though Anonymous is not on, and Response.Write
Request.ServerVariables("LOGON_USER") results in my login name being
displayed, the credentials are not being used to connect to SQL 2005. I will
do some more investigation later.

I have no problem using this connection string:

cn.Open "Provider=sqloledb;Data Source=myserver;" & _
"Initial Catalog=AdventureWorks;Persist Security Info=False;" & _
"user id=xxxx;password=xxxx"

So using SQL Server security is not an option? I can understand why ... it
is less secure.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 16 '06 #13
Not the problem. It must be something in the SQL server setup. I have
created users with full access rights to the database and admin rights to
the server and I still get the same error. Once again, this is setup on a
Win XP system, not a server . The SQL 2005 server is the standard edition. I
can't even log in to server manager with SQL authorization, only windows.

Never had these issues with SQL 7 or SQL 2000 running on the same box. I am
sure that I do not have something set up correctly in 2005. The new and
improved help system is the worst I have ever seen IMO.

Bob Hiller

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Bob and Sharon Hiller wrote:
Bob,
I think I know what may be happening. I believe that you must use a
User ID and Password to connect to the DB in ASP,VBScript. I believe
this because every connection string that uses a trusted connection
works fine in VB 6.0. If I try to use a connection string in VB 6.0
that uses User ID and PassWord I get the following error:
(Login failed for user '<LoginName>'. Reason: Not associated with a
trusted SQL Server connection)


That's probably because you failed to remove the "Trusted_Connection"
attribute when attempting to connect with user id and password.

I have tried every suggestion from MS website on how to setup a User
ID and Password that is associated with a trusted SQL Server
connection but cannot make one work. I have SQL 2005 setup in
authentication mode = SQL Server and Windows


Having said that, I am having trouble connecting with integrated security
from ASP using either MSDASQL or SQLOLEDB. It seems the Windows
credentials
are not being passed correctly. The Event Viewer on my SQL Server has
items
containing:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [CLIENT:
xxx.xx.xx.xxx]

So even though Anonymous is not on, and Response.Write
Request.ServerVariables("LOGON_USER") results in my login name being
displayed, the credentials are not being used to connect to SQL 2005. I
will
do some more investigation later.

I have no problem using this connection string:

cn.Open "Provider=sqloledb;Data Source=myserver;" & _
"Initial Catalog=AdventureWorks;Persist Security Info=False;" & _
"user id=xxxx;password=xxxx"

So using SQL Server security is not an option? I can understand why ... it
is less secure.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 16 '06 #14
Bob and Sharon Hiller wrote:
Not the problem. It must be something in the SQL server setup. I have
created users with full access rights to the database and admin


Using SQL Logins or existing Windows accounts?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 16 '06 #15
Bob,
I set up an account for SQL Login in with admin rights. When I start up
Management Studio I cannot log in as a SQL Server user. I always get the
rights error. If I log in under windows it works fine. Maybe I just don't
know how properly set up user rights under the new security rules.

Bob Hiller

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:em**************@TK2MSFTNGP11.phx.gbl...
Bob and Sharon Hiller wrote:
Not the problem. It must be something in the SQL server setup. I have
created users with full access rights to the database and admin


Using SQL Logins or existing Windows accounts?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 16 '06 #16
Bob,
I just set up the same scenario using SQL server 2000 on a different system.
Windows XP Home. I went in to Enterprise manager and set the server to SQL
and Windows Authentication. It immediately asked me for a password for the
sa account. I entered one and then tested with VB 6.0 and everything works
fine. I tried a few different connection strings and they all worked. Each
time I tried to access the DB it asked for my password just as expected. No
of this seems to happen in SQL 2005. the sa account does not seem to work at
all.

Bob Hiller

"Bob and Sharon Hiller" <ao*****@tir.com> wrote in message
news:uI**************@TK2MSFTNGP12.phx.gbl...
Bob,
I set up an account for SQL Login in with admin rights. When I start up
Management Studio I cannot log in as a SQL Server user. I always get the
rights error. If I log in under windows it works fine. Maybe I just don't
know how properly set up user rights under the new security rules.

Bob Hiller

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:em**************@TK2MSFTNGP11.phx.gbl...
Bob and Sharon Hiller wrote:
Not the problem. It must be something in the SQL server setup. I have
created users with full access rights to the database and admin


Using SQL Logins or existing Windows accounts?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Mar 16 '06 #17
You need to check the server properties and verify that both SQL Server and
Windows Authentication mode are enabled on the Security page.
Open Books Online and paste this into the address bar to see the relevant
Help topic (you can also paste it into the IE browser address field):
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/uirfsql9/html/b8a131c7-e7bd-4203-bf26-
234f1ebfe622.htm
Bob and Sharon Hiller wrote:
Bob,
I set up an account for SQL Login in with admin rights. When I start
up Management Studio I cannot log in as a SQL Server user. I always
get the rights error. If I log in under windows it works fine. Maybe
I just don't know how properly set up user rights under the new
security rules.

Bob Hiller

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:em**************@TK2MSFTNGP11.phx.gbl...
Bob and Sharon Hiller wrote:
Not the problem. It must be something in the SQL server setup. I
have created users with full access rights to the database and admin


Using SQL Logins or existing Windows accounts?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 16 '06 #18
Bob and Sharon Hiller wrote:
Bob,
I just set up the same scenario using SQL server 2000 on a different
system. Windows XP Home. I went in to Enterprise manager and set the
server to SQL and Windows Authentication. It immediately asked me for
a password for the sa account. I entered one and then tested with VB
6.0 and everything works fine. I tried a few different connection
strings and they all worked. Each time I tried to access the DB it
asked for my password just as expected. No of this seems to happen in
SQL 2005. the sa account does not seem to work at all.

See the Help topic I just posted a couple min. ago. The SA account is not
automatically enabled when switching to SQL Server security mode.

You really don't want to be using the SA account in your application
anyways. Guard that account. Somebody could do quite a bit of damage using
that account, not only to your SQL Server, but also to the machine on which
SQL is running, not to mention your network. SA has many more privileges
than will ever be needed by an application. The best practice is to create
a "least-privileges" account, i.e., and account with the fewest privileges
needed to accomplish the tasks performed by the app.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 16 '06 #19
Thanks to all who contributed. After a week of struggle I am finally where I
needed to be 2 weeks ago. At least I finally have a smile on my face.

It is finally working in VB and ASP. Here is what I did. I created SQL login
accounts and re-booted system. They did not work. the sa account did not
even work. I then changed Authentication back to Windows Only(I did not
change any account information). Re-booted again. Changed back to SQL Server
and Windows Authentication and re-booted again.
All accounts are now working as expected.

Hopefully, my final question.
If I want to set up a group of users who can look at one Database and 8 of
the 16 available tables in that database what permissions should I set?
Sincerely,
Bob Hiller
"Bob and Sharon Hiller" <ao*****@tir.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
I have an ASP page that was done in VBScript
It is setup to read an Access database and I need to change it to
read
a Sql 2005 Database.

The code that is used to open the Access Database:

Set adoConnection = server.CreateObject("ADODB.Connection")
Set adoRecordset = server.CreateObject("ADODB.Recordset")
adoConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
Dim strLocation, iLength
strLocation = Request.ServerVariables("PATH_TRANSLATED")
iLength = Len(strLocation)
iLength = iLength - 11
strLocation = Left(strLocation, iLength)
strLocation = strLocation & "../Database.mdb"
adoConnection.Open ("Data Source=" & strLocation)
adoRecordset.ActiveConnection = AdoConnection
In my VB 6.0 app I use the following to open the SQL Database"

Set DataBaseTS_1 = New ADODB.Connection
DataBaseTS_1.ConnectionString ="Provider=MSDASQL.1;Persist Security
Info=False;Extended
Properties=Description=Large Pump Data Source;DRIVER=SQL
Server;SERVER=LPDATASYSTEM\PL3LP;APP=Microsoft Data Access

Components;WSID=LPDATASYSTEM;DATABASE=LargePump;Tr usted_Connection=Yes;Initi
al Catalog=LargePump"

DataBaseTS_1.Open

How can I get the VBScript to open the SQL Database?

Thanks,
Bob Hiller
Lifts for the Disabled LLC

Mar 16 '06 #20
"Bob and Sharon Hiller" <ao*****@tir.com> wrote in message
news:u6**************@TK2MSFTNGP10.phx.gbl...
: Thanks to all who contributed. After a week of struggle I am finally where
I
: needed to be 2 weeks ago. At least I finally have a smile on my face.
:
: It is finally working in VB and ASP. Here is what I did. I created SQL
login
: accounts and re-booted system. They did not work. the sa account did not
: even work. I then changed Authentication back to Windows Only(I did not
: change any account information). Re-booted again. Changed back to SQL
Server
: and Windows Authentication and re-booted again.
: All accounts are now working as expected.
:
: Hopefully, my final question.
: If I want to set up a group of users who can look at one Database and 8 of
: the 16 available tables in that database what permissions should I set?

Please don't top post. This should also be in a new thread and in the db
group. It would give you more opportunity for others to see you have a
second question.

You may need to rephrase because user's should only have access to what your
application allows them to. If you're referring to developers, you're not
restricted to using one account to access a database. You can set
individual permissions on a table for different users, if that's your goal.

--
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
Mar 17 '06 #21
Bob and Sharon Hiller wrote:
Thanks to all who contributed. After a week of struggle I am finally
where I needed to be 2 weeks ago. At least I finally have a smile on
my face.
Great!
It is finally working in VB and ASP. Here is what I did. I created
SQL login accounts and re-booted system. They did not work. the sa
account did not even work. I then changed Authentication back to
Windows Only(I did not change any account information). Re-booted
again. Changed back to SQL Server and Windows Authentication and
re-booted again.
All accounts are now working as expected.
So you did not have to run the ALTER LOGIN command as shown in the Help
topic I pointed you to? Interesting ...

Hopefully, my final question.
If I want to set up a group of users who can look at one Database and
8 of the 16 available tables in that database what permissions should
I set?

You are now getting out of the realm of ASP and into the realm of SQL Server
Security. This is a huge topic and you should start in Books Online. I
have not started working with SQL2005 yet so any advice I could give you may
be outdated. However, in a nutshell:
Add the sql logins to the database without assigning them to a global role
(datareader, datawriter, etc.) in that database.
Edit the properties of the specific tables to which you wish to grant the
users access and choose the option/button/page/tab (whatever it is in 2005
Management Studio) to edit Permissions for the object.

You will get more focussed help in the appropriate sqlserver group ... I
think there is a microsoft.public.sqlserver.security group, but you should
check to be sure.

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 17 '06 #22
Bob,
I could not figure how or where to issue the ALTER LOGIN command. I
switched the Authentication mode a few times and then read in the help file
that you had to have a strong password. I was not sure what that was either.
Another Help search and I changed my login password to a strong one. A soon
as I did that, I got a message box stating that I needed to stop and restart
the SQL Server service before the change would take effect. Instead of
stopping/restarting service I just re-booted. The moral of the story: If you
don't enter a strong password, it does not work. If you do enter a strong
password, re-boot and all is well.

Bob Hiller

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
Bob and Sharon Hiller wrote:
Thanks to all who contributed. After a week of struggle I am finally
where I needed to be 2 weeks ago. At least I finally have a smile on
my face.


Great!

It is finally working in VB and ASP. Here is what I did. I created
SQL login accounts and re-booted system. They did not work. the sa
account did not even work. I then changed Authentication back to
Windows Only(I did not change any account information). Re-booted
again. Changed back to SQL Server and Windows Authentication and
re-booted again.
All accounts are now working as expected.


So you did not have to run the ALTER LOGIN command as shown in the Help
topic I pointed you to? Interesting ...

Hopefully, my final question.
If I want to set up a group of users who can look at one Database and
8 of the 16 available tables in that database what permissions should
I set?

You are now getting out of the realm of ASP and into the realm of SQL
Server
Security. This is a huge topic and you should start in Books Online. I
have not started working with SQL2005 yet so any advice I could give you
may
be outdated. However, in a nutshell:
Add the sql logins to the database without assigning them to a global role
(datareader, datawriter, etc.) in that database.
Edit the properties of the specific tables to which you wish to grant the
users access and choose the option/button/page/tab (whatever it is in 2005
Management Studio) to edit Permissions for the object.

You will get more focussed help in the appropriate sqlserver group ... I
think there is a microsoft.public.sqlserver.security group, but you should
check to be sure.

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 17 '06 #23

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

Similar topics

2
by: Ed | last post by:
I have searched the archives and found several entries that address the problem I'm having, however, the solutions fall short of explaining exactly what to do Like many others, when I attempt to...
5
by: dananrg | last post by:
I've created a small company database where the tables reside in a SQL Server database. I'm using Access 2000 forms for a front end. I've got a System DSN set-up to SQL Server and am using links...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
4
by: rcmail14872 | last post by:
I have MS SQL Server 2000 evaluation version on my desktop PC. I have the SQL Server client tools (only) on the laptop. The two computers are networked. I had an Access MDB database on my laptop,...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
3
by: RayPower | last post by:
I'm having a system using Access 2000 as both front-end (queries, forms, reports & temp tables for reports) & back-end (data) with back-end running on the server. The application runs on the...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: DanZaMan | last post by:
Just a query about how clever access is, I'm using access 97. When using a "split" database with a separate front-end and with the data file on a separate server on the network how does access...
3
by: Bret Kuhns | last post by:
I recently started a co-op/internship at a company and they are looking to migrate a large legacy supported application from OLEDB to SQL Server. I'm doing prelim work in experimenting with the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.