I tried to use integrated security SSIP but it takes anonymous user so any developer can access the database. So anybody have any solution for this problem?
<connectionStrings>
<add name="Local2" connectionString="Data Source=ADMIN-PC\SQLEXPRESS;Initial Catalog=NEOPLAST_LIVE;username="abc" password="****" providerName="System.Data.SqlClient" />
</connectionStrings>
Related
I've created a .net service that work with a database declared in web.config file. Now the project evolved and i need to query more than 1 database, how can i do this in web.config and then specify the database i want to query in the c# files?.
Here's how the current database is specified:
<connectionStrings>
<add name="stringName" connectionString="Data Source=XXXXXXXXX;Initial Catalog=DBName;Persist Security Info=True;User ID=UsrID;Password=bazinga;Application Name=AppName;Connect Timeout=20" providerName="System.Data.SqlClient"/>
</connectionStrings>
Thanks!
You just add another item to the connectionStrings section with a different name specification.
How your program calls the database is another story and I do not have the section of code which is defining the existing one. You would just need to find that and use the same method, just adding another variable to identify it.
<connectionStrings>
<add name="stringName" connectionString="Data Source=XXXXXXXXX;Initial Catalog=DBName;Persist Security Info=True;User ID=UsrID;Password=bazinga;Application Name=AppName;Connect Timeout=20" providerName="System.Data.SqlClient"/>
<add name="stringName2" connectionString="Data Source=XXXXXXXXX;Initial Catalog=DBName;Persist Security Info=True;User ID=UsrID;Password=bazinga;Application Name=AppName;Connect Timeout=20" providerName="System.Data.SqlClient"/>
</connectionStrings>
I have an ASP.net web application hosted in IIS. This application use SQL Server.
I removed connection string in web.config. But when I start the application, it is still connected to it.
The connection string was nowhere explicitly stated.
how does it work?
By default the machine.config located in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config have the following connection string configured.
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
By leaving the <connectionStrings> section of your web.config empty you are not removing the default connectionstring. To ensure that you have no configured connection string you should use a <clear /> element in your web.config file.
<connectionStrings>
<clear />
</connectionStrings>
This is what I have tried to do
<add name="str" connectionString="Data Source=XXX.XX.XXX.XXX;Initial Catalog=immenseshop; Integrated Security=True;Pooling=False" providerName="System.Data.SqlClient"/>
How to change database that web configuration is created?
When I use Asp.net Configuration, visual studio create a default data base (ASPNETDB.MDF),
I want use my database for my web site .
How to do this?
Just add this tab in <connectionStrings> of your Web.Config
<connectionStrings>
<add name="YourConnectionStringName"
connectionString="DataSource=yourDataSource;Initial Catalog=YourDataBaseName;User ID=YourID;Password=YourPassword"
providerName="System.Data.SqlClient" />
</connectionStrings>
You should a add database using this line in web.config
replace with aspnetdb connection string
<connectionStrings>
<add name="LoanCalculatorConnectionString" connectionString="Data Source=servername;Initial Catalog=dbname;Persist Security Info=True;User ID=888;Password=8888"
providerName="System.Data.SqlClient" />
</connectionStrings>
To this porpus use this way:
C://windows/Microsoft.net/Framework/v2.0.50727/aspnet_regsql.exe
. is run
Next--> Configuration SQL server for application service --> select server and database --> Next --> Finish
I am have a register page on my website built in VS2010 and when I fill the form in a click register I am getting the following error. Help would be appreciated.
System.Exception was unhandled by user code
Message=Insert Error:Directory lookup for the file "C:\Users\myname\Documents\myname\Project\App_Data\SJDatabase.mdf" failed with the operating system error 5(error not found).
Cannot attach the file 'C:\Users\myname\Documents\myname\Project\App_Data\SJDatabase.mdf' as database 'SJDatabase'.
connection string:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="MyConsString" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|SJDatabase.mdf;
Initial Catalog=SJDatabase;
Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
I think you are missing a backslash on |DataDirectory|\SJDatabase.mdf
also, you have Integrated Security=SSPI twice and I dont think you need the AttachDBFileName part
try something more simple like this:
"data source=ServerName;Initial Catalog=SJDatabase;Integrated Security=SSPI" providerName="System.Data.SqlClient"