I've got a local working connectionstring which is displayed below but I need a little change in it to make it applicable for a network.
I've tried to do it with a static ip but it didn't work. Already checked that the connection to the other device is stable.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="BeursTD.Properties.Settings.sdtcaptConnectionString"
connectionString="Data Source=levi\SQLEXPRESS;Initial Catalog=sdtcapt;User ID=XXXX;Password=XXXX"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Try using something like
connectionString="Server=192.168.1.1,1433; Network Library=DBMSSOCN;Initial Catalog=mbc;User ID=xxxx;Password=xxxxx"
This points to the specific computer running the DB on the network
1433 is the default port for SQL server, so if yours is different you will need to change it.
This is used on SQL Server 2014
Related
I have a app.config xml file to save entity framework's connection strings as the following example:
<configuration>
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/EntityFramework.MyEntities.csdl|res://*/EntityFramework.MyEntities.ssdl|res://*/EntityFramework.MyEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=myserver;initial catalog=Example;persist security info=True;user id=myId;password=myPassword;multipleactiveresultsets=false;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
But I'm using ASP.NET Core, I manage multiple servers with an enviroment variable. so I need to save this connection string in my appsettings.{enviroment}.json, read this connection and set to the property entity framework context.
I think you are looking for something like the following construction.
"ConnectionStrings": {
"MyEntities": "metadata=res://*/EntityFramework.MyEntities.csdl|res://*/EntityFramework.MyEntities.ssdl|res://*/EntityFramework.MyEntities.msl;provider=System.Data.SqlClient;provider connection string="data source=myserver;initial catalog=Example;persist security info=True;user id=myId;password=myPassword;multipleactiveresultsets=false;application name=EntityFramework"
}
Not sure if this is the correct way to do this, but this may be a good starting point for you. I've added the configuration settings into the file named app.config. It appears that the contents in the files are written into the exe's config file. When the exe is executed the config settings are also loaded. I have just starting experimenting with .NET Core, so this may not be the recommended or correct way.
<configuration>
<runtime>
<gcServer enabled="true"/>
</runtime>
<connectionStrings>
<add name="TestName" connectionString="data source=MyServer;initial catalog=MyDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
I have an application that runs on SQL 2005 database
I m trying to use same application on another machine same network,
I managed to log in on SQL 2005 using IP
Now I need to configure applications app.config file (found in visual studio solution) to allow connection
soo far I tried this connection string which isn't worked
this is what my config file looks like
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="Data Source=ipaddress,1433;Initial Catalog=sample;User ID=sample;Password=sample;Trusted_Connection=True;" />
</appSettings>
</configuration>
Any help would be appreciated
Add this to your config file. Rather then using an appSetting use the actual connectionStrings section.
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=00.000.0.00,1433;Initial Catalog=taxi;Persist Security Info=True;User ID=sample;Password=sample; providerName="System.Data.SqlClient" />
</connectionStrings>
This string should work if anyone else got the same problem
thanks everyone for looking and trying to figure it out with me
<add key="ConnectionString" value="Data Source=00.00.000.000;Initial Catalog=sample;User ID=sample;Password=sample;" />
I am working with the existing structures used by the dev team at my current company. In order to change connection strings within the application, the team creates an XML node called "defaultDatabase" (see below):
</configSections>
<dataConfiguration defaultDatabase="Development" />
<connectionStrings>
<add name="Development" connectionString="Data source=DVHQSQL01; Initial Catalog=db; User ID=id; Password=password"/>
</connectionStrings>
...there will be more connection strings in the XML for different server environments (not shown here, but "Testing", "Staging", "Production", etc)
I am creating a class with different functions that use the default connection. I know one route is through ConfigurationManager as shown here:
https://social.msdn.microsoft.com/Forums/en-US/9a8c9f5a-092e-4c4a-87bb-9f35d8f55da1/get-connection-string-from-appconfig-file?forum=adodotnetdataproviders
This is great if you can change the connection string name in code, but we use the defaultDatabase node to be able to change from different environments without rebuilding.
Does anyone have experience with this methodology? How do I get the correct connection string using the defaultDatabase node?
Just set the default connection in the connection strings area:
<connectionStrings>
<add name="default" connectionString="..."/>
</connectionStrings>
If you have further connections you can add them in the same way:
<connectionStrings>
<add name="default" connectionString="..."/>
<add name="special1" connectionString="..."/>
<add name="special2" connectionString="..."/>
</connectionStrings>
You can have as many connectionStrings as you want in your config, all you have to do is give them different names.
<connectionStrings>
<add name="default" connectionString=""/>
<add name="anotherOne" connectionString=""/>
...
</connectionStrings>
I'm developing a website for sharepoint using asp.net, it is connected to a database. In visual studio server explorer, the database is accessible using a new sql user I created. I granted sysadmin permissions to that user. However, when I deploy the site and run it, it gives me this error 'login failed for user'.
The sql server is configured to allow mixed authentications. I restarted the server, I played with the user permissions but nothing ever changed.
The connection string I got it from server explorer which I'm sure it is correct:
Data Source=servertest;Initial Catalog=qDB;User ID=me2;Password=***********"
What should I do? I've tried every possible solution I found on google and I ended up here.
Try like this by editing your connection string:-
Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;
I too had same scenario this worked for me
<connectionStrings>
<add name="connectionstring" connectionString="Data Source=XYZ\SHAREPOINT;Initial Catalog=DBName;Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
You can Use connection string like this
<appSettings>
<add key="KhadamatConnectionString"
value="Server=[copy name from Your ServerName of SSMS];Database=AcaService;uid=admin;pwd=mypass;" />
</appSettings>
or
<connectionStrings>
<add name="KhadamatConnectionString" connectionString="Data Source=[copy name from Your ServerName of SSMS];Initial Catalog=AcaService;User ID=admin;Password=mypass;" providerName="System.Data.SqlClient"/>
</connectionStrings>
i have a website that used to run on sqlexpress data base i changed my server and it stopped running i ran it using visual studi and IIS but it eith gives me error 404 or error 503 i think the problem is in my webconfig sql string connection her is my code:
<connectionStrings>
<add name="SiteSqlServer" connectionString="Data Source=localhost;Initial Catalog=ULTRA; User ID=admin;Password=123" providerName="System.Data.SqlClient" />
<add name="SiteSqlServer" connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;" providerName="System.Data.SqlClient" />
-->
<!-- Connection String for SQL Server 2008/2012 Express -->
<!--<add name="SiteSqlServer" connectionString="Data Source=localhost;Initial Catalog=ULTRA; User ID=admin;Password=123" providerName="System.Data.SqlClient" />-->
<!-- Connection String for SQL Server 2008/2012
-->
<!--<add name="SiteSqlServer" connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;" providerName="System.Data.SqlClient" />-->
</connectionStrings>
<appSettings>
<!-- Connection String for SQL Server 2008/2012 Express - kept for backwards compatability - legacy modules -->
<!--<add key="SiteSqlServer" value="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True" />-->
<!-- Connection String for SQL Server 2008/2012 - kept for backwards compatability - legacy modules
-->
<add key="SiteSqlServer" value="Server=(local);Database=DotNetNuke;uid=;pwd=;" />
would someone please help me to tell me what is wrong?
You have your connection string defined multiple times in the ConnectionStrings section of the web.config. Which is the proper connection string?
EDIT:
You likely have an issue with the PortalAliases and your IIS configuration. What is the URL that you are trying to access the website using? Make sure that URL is listed in the PortalAliases table, also make sure that IIS will respond to the URL as well.