I'm working on C# linq-to-sql application over SQL Server express 2008 . My database is inside SQL server.
I'm using Windows Authentication to connect to sql server from my application.
The server name used in connection string is related to my pc user name, so I'm wondering if I create a release of my application and put it on client pc which have SQL Server installed with another server name, would my application work?
my connection string is
<add name="WindowsFormsApplication1.Properties.Settings.OPTICA_MDFConnectionString"
connectionString="Data Source=ENG-MEDIAN-PC;Initial Catalog=OPTICA.MDF;Integrated Security=True"
providerName="System.Data.SqlClient" />
Because the app and the sql server are on the same host you can use "Data Source=.\<instance name>" which may be the default MSSQL.
That default would look like this:
connectionString="Data Source=.\MSSQL; ... "
For another example, our developer boxes' app.config uses this:
connectionString=".\DEVSQL;Initial Catalog=..."
Note that the "." is the host and that "DEVSQL" is the sql server instance name.
Related
I bought a Windows hosting from GoDaddy. I have configured the configuration settings(Adding database and publishing project's files to host)
I can access the database while running the project on the local server.
But when I transfer the project to the server, the project on the server can't do it.
I wrote my connection string to web.config file, here it is:
<add name="xyz" connectionString="Data Source=IP ADDRESS;Initial Catalog=DBNAME;User ID=USERNAME;Password=PASS;Integrated Security=False" providerName="System.Data.SqlClient" />
I used MVC and Entity Framework, I also used layered structure
Thank You.
try to check more details about the connection string that should be used with your database provider. Here you can find several examples about how to create your connection string properly in SQL SERVER.
please notice that if you are working in your host machine, you have not to specify the IP ADDRES of your SQL SERVER but the SERVER NAME just like:
Data Source=(SERVER_NAME) \ DB_INSTANCE_NAME
I hope that it's gonna be useful.
I have a WPF application holding a LINQ to class database, now I need to publish this application to work on client's machine.
I have done this but it doesn't work like if the database was not found, I think my problem is that the database is not included in the deployed files, so I need help with a clear steps to publish my application including my database.
Thanks in advance
It's not possible to interact with your .mdf database without having SQL Server engine installed on your client machine .
Try this:
Install SQL server Express on your Client machine
Attach database to the SQL Server (using .mdf or using a DB backup)
then change your connection string before deploying the application in client machine.
if you've hard coded the connection string then , you'll have to change the connection string to adjust client's machine name , or add you connection string inside app.config in order to give you the flexibly to modify it after deployment .
App.Config:
<configuration>
<connectionStrings>
<add name="Test" connectionString="Data Source=.;Initial Catalog=OmidPayamak;IntegratedSecurity=True" providerName="System.Data.SqlClient" />
</connectionStrings>
using
var connection = ConnectionFactory.GetConnection(ConfigurationManager.ConnectionStrings["Test"].ConnectionString, DataBaseProvider);
wish it help .
I need to deploy WCF. Database is SQL Server 2008 R2. Access to database is only possible from app server because of Windows Authenticaton (sql server authentication not work).
I need to change my connection string to new data source i tried but not successfull.
i have connection address and everything what i need.
My connection string :
<connectionStrings><add name="MyEntities" connectionString="metadata=res://*/MyDatabase.csdl|res://*/MyDatabase.ssdl|res://*/MyDatabase.msl;provider=System.Data.SqlClient;provider connection string="data source=myMachine-LAPTOP;initial catalog=MyDatabaseName;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /></connectionStrings></configuration>
to delete connection string and generate new is not possible, because i have not access from dev computer and app server dont have visual studio to try it from there.
i need help how to change it.
Please try to change connection string by opening configuration file with notepad..
I am using this connection string for SQL Server Professional. It is ok...
<add name="bd1" connectionString="Provider=SQLOLEDB.1;
Data Source=10.180.0.2;
User ID=sa;
Password=1234;
Initial Catalog=aa" />
But when I change for SQL Server Express 2008. Doesnt work.
String connection
<add name="bd1" connectionString="Provider=SQLOLEDB.1;
Data Source=10.180.0.8;
User ID=sa;
Password=1234;
Initial Catalog=aa" />
I have this error
[DBNETLIB][ConnectionOpen (Invalid Instance()).]Invalid connection.
By default, SQL Server Express installs as a "named instance", as \SQLEXPRESS. Technically, any SQL server instance can be installed as a "named instance" (under any name), and SQL Server Express can be installed under a different name, or as the default instance - these are just the installer defaults, but: they are common defaults.
To connect to a "named instance" (rather than the default instance), the instance name must be included in the connection string - i.e.
Provider=SQLOLEDB.1;Data Source=10.180.0.8\SQLEXPRESS;User ID=sa;...etc
Hello everybody i have a question and confusion about a project that i developed, and I will be very happy if you help me to improve my project.
I worked in VS2010 with C# and my database is attached in Sql Server 2008. my app is supposed to work in a LAN, so i'm thinking to make two versions of this app, the first will include the database and the sql server(plus the winforms of course), the second will just contain dotNet framework and it's supposed to connect to the database installed on the other machine. Is it possible. If so, how??
yes it is posible.
alter your connection string's "data source" to "ip address of the server"
Suppose in your machine where sql server is installed you are using this connection string
"data source=localhost;initial catalog=databasename;uid=sa;pwd=password"
then in the client system you need to alter it like this
"data source=IpAddressOfTheServer;initial catalog=databasename;uid=sa;pwd=password"
Note: the application having server's ip address in connection string is accessible by both, server and the client.
if Connection String in your (c# ) code Setted, Change connection string's "Data Source" to "IP address of server"
an another way change connection string in (App Config or WebConfig) at StartUp Project by below format:
<configuration>
<connectionStrings>
<add name="DB" connectionString="Data Source=192.168.10.5;
Initial Catalog=SafetyDB;Persist Security Info=True;User ID=sa;
Password=a1234$; connection timeout=5000" />
</connectionStrings>