473,394 Members | 2,048 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,394 software developers and data experts.

Connection string confusion

I have never really understood connection strings. I'm not sure why, as I'm
a smart guy otherwise, but I cannot make sense of any of the explanations I
have seen out there over the past 7 or so years that I have been doing ASP.
I have somehow just managed to get by with copying existing connections
strings, and making changes until it works.

This time, however, I am at a loss. I have an ASP 3 app, which is on my
local machine (WinXP Pro) for now, but will be uploaded to a real host for
viewing my on a members-only site. It will use SQL Server 2005. I had it
working fine with Access, but I had to move the db over to SQL Server,
because that's what it's going to be in Production.

I have tried variations of the different attempts you can see below. I have
read www.connectionstrings.com and www.aspfaq.com.

I currently have SQL Server set for Windows Authentication. I have no
problem setting it for Mixed Mode, but have not figured out why.

I have verified that IUSR_(machinename) is a user on the machine.

The errors I get, depending on which of the various attempts I make, are
usually some sort of permissions error. Any help appreciated.

strDBConnection = _

"Provider=SQLOLEDB;Persist Security Info=False;Data Source=machinename;" &
_

"User ID=userid;Password=password;Database=1;"

Dim objConnection

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

objConnection.Open strDBConnection


and

strDBConnection = "Provider=SQLOLEDB;" & _

"Data Source=<machinename>\<SQLEXPRESS>;" & _

"Initial Catalog=<shape>;" & _

"Integrated Security=SSPI"
set conn = CreateObject("ADODB.Connection")

conn.open strDBConnection

and

set db = Server.CreateObject("ADODB.Connection")

strConnect = "Provider=SQLOLEDB; Data Source=machinename; Initial
Catalog=shape; User ID=userid; Password=password; Network Library=dbmssocn;"

and

strConnect = "Provider=SQLOLEDB;Driver=SQL
Server;Server=machinename;Database=shape;"

db.Open strConnect
May 24 '07 #1
19 2506
I currently have SQL Server set for Windows Authentication. I have no
problem setting it for Mixed Mode, but have not figured out why.
that should say:

but have not figured out *how.*
May 24 '07 #2
"Middletree" wrote:
>I currently have SQL Server set for Windows Authentication. I
have no problem setting it for Mixed Mode, but have not figured
out why.

that should say:

but have not figured out *how.*
SQL Server Management Studio
Right-click on server, select Properties
Click on Security
Set authentication to desired mode


--
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.

May 25 '07 #3
"Middletree" wrote:
I have never really understood connection strings. I'm not sure why,
as I'm a smart guy otherwise, but I cannot make sense of any of the
explanations I have seen out there over the past 7 or so years that
I have been doing ASP. I have somehow just managed to get by with
copying existing connections strings, and making changes until it
works.
Use these instructions to create a data link (UDL file):
http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

Proceed to the "Test Connection" part. If you succeed in connecting, click
OK and elect to save. Then open the file in notepad (UDL files are just text
files, after all). You have your connection string.


--
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.

May 25 '07 #4
Thanks!

SQL Server Management Studio
Right-click on server, select Properties
Click on Security
Set authentication to desired mode

May 25 '07 #5
Perhaps this is a SQL Server question, but I cannot seem to make this work,
because it says that the user I created is not a trusted SQL Server
connection. I created a new user and login and am trying to use that, but I
get that error when I try to go through the UDL steps and point to that
user.
>
Use these instructions to create a data link (UDL file):
http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

Proceed to the "Test Connection" part. If you succeed in connecting, click
OK and elect to save. Then open the file in notepad (UDL files are just
text files, after all). You have your connection string.


--
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.

May 25 '07 #6
Middletree wrote:
Perhaps this is a SQL Server question, but I cannot seem to make
this work, because it says that the user I created is not a
trusted SQL Server connection. I created a new user and login and
am trying to use that, but I get that error when I try to go
through the UDL steps and point to that user.
Are you getting the "not a trusted connection" error when configuring the
UDL and pressing [Test Connection], or when using the connection string?
--
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.
May 25 '07 #7
When configuring the UDL. I never get to the point of testing the
connection. As sson as I try to select a default database, I get a popup
with the error.

Note that for testing purposes, I created, just this morning, a login called
"asp" with a password of "asp" (I'll make it more secure later; just want to
get the process down). I then got this error. So in the specific database I
am using, I opened "Security" and created a user and tied it to that login.
SQL Server had no problem accepting this. I only got hte error when I went
back to the UDL screen.

>
Are you getting the "not a trusted connection" error when configuring the
UDL and pressing [Test Connection], or when using the connection string?
--
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.

May 25 '07 #8
This is weird. When I changed the UDL to Windows authentication, the "Test"
button worked fine, but the connection string, when used in the ASP page,
still gave me a "Cannot open database "SHAPE" requested by the login. The
login failed." message.
May 25 '07 #9
Middletree wrote:
This is weird. When I changed the UDL to Windows authentication, the
"Test" button worked fine, but the connection string, when used in
the ASP page, still gave me a "Cannot open database "SHAPE" requested
by the login. The login failed." message.
That's because you are using Windows Authentication. I thought you said you
were going to set it to "mixed".

--
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.
May 25 '07 #10
I wrote:
That's because you are using Windows Authentication. I thought
you said you were going to set it to "mixed".
I should add that (1) I assume you are NOT trying this with SQL Server 2005
Express, Evaluation or Developer editions (see:
http://msdn2.microsoft.com/en-us/library/ms178763.aspx), and (2) you have
already done the [User Mapping] for the SQL Server login used in the
connection.

To be absolutely certain, connect to the database with the Management
Studio, open [Security], and look at the properties for the Login. Clike
[User Mapping], and ensure that the DB in question is checked.

--
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.
May 25 '07 #11
I did set it to Mixed, and I am using Express.

Doing some Googling, I am finding that a lot of people are having trouble
connecting to Express.

The User Mapping does have the correct DB checked.

I tried to connect to SQL Server using the new user I created, and I got the
"not trusted" error again. I think the problem is with SQL Server, not my
ASP connection string.

thanks
"Dave Anderson" <NP**********@spammotel.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I wrote:
>That's because you are using Windows Authentication. I thought
you said you were going to set it to "mixed".

I should add that (1) I assume you are NOT trying this with SQL Server
2005 Express, Evaluation or Developer editions (see:
http://msdn2.microsoft.com/en-us/library/ms178763.aspx), and (2) you have
already done the [User Mapping] for the SQL Server login used in the
connection.

To be absolutely certain, connect to the database with the Management
Studio, open [Security], and look at the properties for the Login. Clike
[User Mapping], and ensure that the DB in question is checked.

--
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.

May 25 '07 #12
[please do not toppost]

"Middletree" wrote:
>I should add that (1) I assume you are NOT trying this with SQL
Server 2005 Express, Evaluation or Developer editions (see:
http://msdn2.microsoft.com/en-us/library/ms178763.aspx), and (2)
you have already done the [User Mapping] for the SQL Server
login used in the connection.
I did set it to Mixed, and I am using Express.
Well, did you look at the link I provided about it? Ahem:

"By default, SQL Server 2005 Express, Evaluation, and
Developer editions allow local client connections only."


--
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.

May 26 '07 #13
Well, did you look at the link I provided about it? Ahem:
>
"By default, SQL Server 2005 Express, Evaluation, and
Developer editions allow local client connections only."
But this was local.
May 27 '07 #14
"middletree" wrote:
But this was local.
OK. I had to ask.

Are you able to connect with ANY tool (like a data link) using a SQL Server
Login and password, or can you only connect using Windows Authentication?

--
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.

May 27 '07 #15
Sorry it's been a while since I got back on this. I am out of town on
business and have been for several days.

I appreciate your help and suggestions. I suspected that it might be
something to do with SQL Server Express, so I uninstalled it and installed
SQL Server Standard. It works just fine now.

thanks
Jun 3 '07 #16
Middletree wrote on 03 jun 2007 in
microsoft.public.inetserver.asp.general:
Sorry it's been a while since I got back on this. I am out of town on
business and have been for several days.

I appreciate your help and suggestions. I suspected that it might be
something to do with SQL Server Express, so I uninstalled it and
installed SQL Server Standard. It works just fine now.
Seems you are responding to someone on something, thinking this is email.

[please always quote on usenet]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 3 '07 #17
Seems you are responding to someone on something, thinking this is email.

[please always quote on usenet]

I do not think this is email. Mind your own business.
Jun 7 '07 #18
Middletree wrote:
>[please always quote on usenet]

I do not think this is email. Mind your own business.
No need to be upset with Evertjan. I would not have recognized your post as
part of my conversation with you if he had said nothing. The manner with
which he makes his point may not be optimal, I agree.


--
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.
Jun 7 '07 #19
>The manner with which he makes his point may not be optimal, I agree.
>
I don't agree with his method of making his point or his point. The rules
against top-posting, while long entrenched, are silly. Most people I know
prefer to read top-posted replies. It's certainly not a consensus. And in
this case, it's another unwritten rule against replying without quoting. But
most of all, it seems he has come into a thread he wasn't part of, and
corrected my actions, in a rude way, to boot.
Jun 7 '07 #20

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

Similar topics

2
by: moosedeja | last post by:
I have an ASP (IIS 4.0) based website fronting a SQL Server 2000 database. I am trying to avoid using dynamic SQL for queries, and I am considering prepared statements as an alternative... All...
4
by: RedRed | last post by:
Hi all, Hi to connect to database if I want to write the code in the class instead in the html (.aspx). What I want to do is to create a reusable class which allow the other page to connect...
6
by: Mike Moore | last post by:
I'm not very familiar with the web config file. I would like to use the timeout item in the session state for our connection string, but not use the stateconnection string and sqlconnectionstring...
4
by: Bill | last post by:
Hi, I would be grateful if someone could clarify my rather confused ideas of the 10 connection limit on XP/2000 when its being used as a server. (I realise that XP is really a client op sys with...
7
by: Mrinal Kamboj | last post by:
Hi , I am using OracleConnection object from Oracle ODP.net provider and following is the behaviour which i am finding bit strange : To start with my argument is based on followings facts : ...
3
by: thejamie | last post by:
My question: "What is the correct connection object to use in VS 2005 for a text connection?" will need some background. I am placing code at the end showing how I am reading data from a text file...
39
by: sucaba.r | last post by:
I don't know if this is a unique problem, or I'm going about it the wrong way. I currently connect to one of our SQL servers via a priviliged account (by using RUNAS). Works with no problem. I...
5
by: Sam | last post by:
Hi all, I have a process which first pulls one time all application IDs from a database and stores them in a table(this process works fine everytime). I then loop through the table, one at a...
5
by: OJ | last post by:
Hi, I am at a loss here, I have a c# asp.net website which connects to a remote SQL Server 2000 db via a connection string. If I set the website up in the filesystem and use the inbuilt cassini...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.