My website, an ASP.NET MVC app, is working perfectly inside Visual Studio with database entities and such. I want to try to upload my app to GoDaddy's Plesk Web Service.
I got a guide here:
http://www.c-sharpcorner.com/article/how-to-host-your-asp-net-mvc-website-on-godaddy-server/
which says at step 19: "Write Connection String for your server side database."
and at step 20 "Open Visual Studio again and update database from package manager, again writing same connection string in web.config of your project in Visual Studio. Open package manager console and type the following command,"
Can anyone of you please give me some advice what it means by connection string?
There is connection string in web.config file.
I am using entity framework so my connection string is as per below
<add name="yourEntityName" connectionString="metadata=res:///entity.csdl|res:///entity.ssdl|res://*/entity.msl;provider=System.Data.SqlClient;provider connection string="data source=yourServerIpAddress;****initial catalog=DataBaseName;persist security info=True;user id=YourId;password=YourPassword;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
you have to change lines in your connection string where bold line in my conn. string.
Related
I need help solving this problem. I created the application installer using MS Visual Studio Installer Projects and ran it on another device. There were no versions of LocalDB that installed on my computer (2016 and 2017) in the prerequisites, so I had to download the SQL Server 2017 LocalDB on another computer manually. After that, when I started the program I received the following error.
Database files were automatically placed during installation in the folder Documents
I changed the connection string as follows:
string dbPathMyDoc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string dbPath = Path.Combine(dbPathMyDoc, "myprojectAppData");
AppDomain.CurrentDomain.SetData("DataDirectory", dbPath);
Database path
So it seems to me that the problem is not the connection string, but then what?
I found that I can not check the version of SQL Server LocalDB installed on a second computer through the Command Prompt using the command sqllocaldb info MSSQLLocalDB (because of an error).
So I decided to recreate the MSSQLLocalDB instance using the following commands:
1) sqllocaldb d MSSQLLocalDB
2) sqllocaldb c MSSQLLocalDB
And after that the program successfully connected to the database.
I hope this information helps someone.
I make sample fixed problem for all project when create ny winforms & localdb
You can create 2 ConnectionString in App.config file
App.config
<add name="DevConnectionString"
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MyDatabase.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" /> <!-- *1* Use when publish project-->
<!--<add name="AppConnectionString"
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='E:\My Projects\MyDatabase.mdf';Integrated Security=True"
providerName="System.Data.SqlClient" />-->
<!--*2* Use for development-->
First use when you want develop system Developer Environment
Second CS use when app publish Publish Environment
For second connection-string must write full path
Code
For get connection String in App.config file, you can use this code
var conStr = ConfigurationManager.ConnectionStrings["DevConnectionString"].ConnectionString;
Initially I developed my project by putting the .db file within the project folder. Now I want to host the database on localhost so I put the db file on a new folder and started a http-server using node.js on localhost:8080. To start the server I used this command on node.js command line C:\Users\Me\aswserver>http-server .
aswserver folder contains only aswDB.db.
On my C# project until now I used the connection string
<connectionStrings> <addname="SQLite"connectionString="DataSource=.\aswDB.db;Version=3;"providerName="System.Data.SQLClient"/>
</connectionStrings>
and included the db file to project(Build Action: Content and Copy to output if newer).
After hosting the db on localhost I tried this connection string
<connectionStrings>
<add name="SQLite" connectionString="Data Source=localhost:8080/aswDB.db;Version=3;" providerName="System.Data.SQLClient" />
</connectionStrings>
Now when I try to connect to the db from the project I get Exception saying "The given path's format is not supported". How do I set up the connection so that any change I make to the db stays in aswDB.db on the server? (I plan to connect it to a Xamarin.android app too)
I've seen this error answered for other people, but I can't seem to get it to work. I'm trying to connect to a SQL Server Database project locally.
I'm getting this error thrown on Open() when I do the follow:
SqlConnection conn = null;
conn = new SqlConnection(connection)
conn.Open()
Where connection is a connection string passed from my webconfig. I've found examples online and tried these three connection strings and I get the same error every time:
<add name="TICKETING_CONNECTION" connectionString="Server=(local); DataBase=Ticketing_DB; Integrated Security=SSPI"/>
<add name="CONN"
connectionString="Data Source=localhost; Integrated Security=SSPI;Initial Catalog=Ticketing_DB"
providerName="System.Data.SqlClient" />
<add name="CONN2"
connectionString="Data Source=(local);Initial Catalog=Ticketing_DB;"
providerName="System.Data.SqlClient"
/>
Could the problem be stemming from the path of where the database is located on my machine? I've tried copying the c:\ path but didn't have any luck. I've seen some examples online use a .mdf file, but my project does not have this file either.
This is my first time trying to connect to a database project, so any help or advice would be greatly appreciated
If you are using Visual Studio try going to the Server Explorer and Right click on Data Connections and Add new connection by selecting DataSource as Microsoft SQL Server and provider as .net framework provider for SQL Server.
Under the server name check for the SQL Server if it is listed with your machine name.
Then try to provide the database details and user name and password for SQL Authentication or select windows for windows authentication. Then do a test connection. If it is fine on click of OK it will add the data connection.
Right click the properties of data connection which is newly added and navigate to properties to extract the connection string. Compare it with yours. This can help you troubleshoot the issue.
I'm having a problem switching a project I am working on over to another system. It's an ASP.Net web application and web form wrapped in a single solution, with a SQL .mdf DB file in the project as well. I'd like to be able to zip up the whole thing and move it around, but when trying to debug the solution on the other machine I get an error about the local DB not existing. My connection string in the Web.Config file looks like this:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-name-of-database.mdf;Initial Catalog=aspnet-name-of-database;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
I know I must be making an obvious mistake, but I can't figure out what it is. Any advice, please? Thanks.
Edit: The specific error is:
"The specified LocalDB instance does not exist."
Run the following from your package manager console:
SqlLocalDb info
If the executable isn’t found, chances are you do not have LocalDb installed in your new machine. You can use the steps mentioned in the below link to debug as to why the connection is not successful to your localDB:
http://odetocode.com/blogs/scott/archive/2012/08/15/a-troubleshooting-guide-for-entity-framework-connections-amp-migrations.aspx
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True
Try setting the Datasource as below.
Data Source=.\;
If you are able to connect to your database, then the set the ServerName as DataSource in your connection string.
Make sure you have SSMS installed in your new system.
Download SQL Server Express 2014
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..