ullenulle
asked on
Connection string to SQL Server Express database on virtual Windows Server 2016...
Hi there.
I have some trouble with the connection string on my Windows 2016 Server with SQL Express server. I'm used to a connection string like this on a standard web hotel:
"Driver={SQL Server};Server=webhotel.co m\MSSQL200 5;Database =database_ name;Uid=d b_username ;Pwd=db_pa ssword"
Since I run web and SQL on the same Windows Server I'm a little confused how to write the connection string to make it work AND to be safe. I'm hesitant to write username and password in the connection string.
I hope some of you with a similar setup can give me a useful hint. My web app is classic asp/aspx/VB.
Best regards
Ulrich
I have some trouble with the connection string on my Windows 2016 Server with SQL Express server. I'm used to a connection string like this on a standard web hotel:
"Driver={SQL Server};Server=webhotel.co
Since I run web and SQL on the same Windows Server I'm a little confused how to write the connection string to make it work AND to be safe. I'm hesitant to write username and password in the connection string.
I hope some of you with a similar setup can give me a useful hint. My web app is classic asp/aspx/VB.
Best regards
Ulrich
ASKER
Hi Vitor.
The webhotel.com\MSSQL2005 is the way it is and isn't an issue. That one works fine. The problem is on my new dedicated server. On the Server Manager I found a connection string like this:
data source=.\SQLEXPRESS;Integr ated Security=SSPI;AttachDBFile name=|Data Directory| aspnetdb.m df;User Instance=true
Is that what I'm supposed to use as a connection string? I usually referred to the connection string in a separate asp-file. Is it better in an asa.file or something else? Is it necessary at all with Integrated Security?
Best regards
Ulrich
The webhotel.com\MSSQL2005 is the way it is and isn't an issue. That one works fine. The problem is on my new dedicated server. On the Server Manager I found a connection string like this:
data source=.\SQLEXPRESS;Integr
Is that what I'm supposed to use as a connection string? I usually referred to the connection string in a separate asp-file. Is it better in an asa.file or something else? Is it necessary at all with Integrated Security?
Best regards
Ulrich
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Vitor.
Thank you for clearing that up with the "." at SQLEXPRESS. I added the server name.
Say I would like to keep the Integrated Security. If a user login to the web app with the login that also gives acc ess to the SQL server. Is that possible? Or is it necessary to create a SQL server account and add the credentials to the connection string?
Thank you for clearing that up with the "." at SQLEXPRESS. I added the server name.
Say I would like to keep the Integrated Security. If a user login to the web app with the login that also gives acc ess to the SQL server. Is that possible? Or is it necessary to create a SQL server account and add the credentials to the connection string?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK. So say I stick to the secure option where a user will enter the credentials for the SQL server. How is the connection string supposed to be written, and where should I store it?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok. I tried saving a global.asa in the root of the webfiles:
Of course I replaced servername, username and password with the real values. But then no page on my website will show up. I just get the Server 500 error. If I move the global.asa away from the root, then the webfiles works again. What am I doing wrong?
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
Dim cnnDem, cnnString
Set cnnDem = Server.CreateObject("ADODB.Connection")
cnnDem.CommandTimeout = 60
cnnString = "Driver={SQL Server};Server=servername\SQLEXPRESS;Database=mcd;Uid=username;Pwd=password"
Application("conString")=cnnString
Application("cnn")=cnnString
Call cnnDem.Open(cnnString)
End Sub
</SCRIPT>
Of course I replaced servername, username and password with the real values. But then no page on my website will show up. I just get the Server 500 error. If I move the global.asa away from the root, then the webfiles works again. What am I doing wrong?
I'm not an ASP expert so I can't help you with the .asa file.
Let's wait for some ASP expert or you can try to open a new question only in ASP area to get this specific issue helped in that topic area.
Let's wait for some ASP expert or you can try to open a new question only in ASP area to get this specific issue helped in that topic area.
ASKER
Ok. Problem was the \SQLEXPRESS in the string. I tried deleting that part, and bingo it worked. :-) Thank you all for your responses.
ASKER
Thank you.
I would expect something like servername\SQLEXPRESS.