I have made my WPF project reports by stimulsoft reports with this SQL server connection string
Data Source=.;Initial Catalog=DBNBO;Integrated Security=True;
I want to make a setup file for my project by Advanced Installer program for this purpose I have transferred my database to SQL express and I have moved MDF and LDF file to my debug project file. I need to change reports SQL connection string in stimulsoft reports so that it can execute correctly; but I don't know how to do this.
Can anybody help me, please?
If you need to save the SQL connection string, set during install time on your installer dialogs, into a config file then try to implement into your setup project similar settings like exposed in Advanced Installer help file.
Related
I am creating an on-line shop project using .NET Core 3.0 and Entity Framework Core. I have set up the applicationContextDb and the connection string in appSettings.json.
The application works just fine adding products, and these products show up in my localdb in VS2019. I need it to connect to my localhost SQL Server instance in SSMS as it will be easier in the future to manage the online shop and see the data, but I don't know how to do that and I cannot find much information about this out there. Does anyone have an idea on how to do this?
I have tried to change the name from localdb to localhost, and obviously changing it too in the connection string, but it throws an error saying that it cannot find the network path.
To connect to a local default SQL Server instance (which I agree is easier in the long run than localDB), use a connection string like:
"Server=localhost;database=YourDatabaseName;Integrated Security=true"
A named instance like
"Server=localhost\SqlExpress;database=YourDatabaseName;Integrated Security=true"
Of course you have to install the SQL Server instance before this will work. You can install using the Developer Edition or Express Edition available for free download here.
After pointing to the new instance, you'll need to run your Migrations, or run myDbContext.Database.EnsureCreated() to generate the DDL for your EF model. Or copy the .mdf/.ldf into your SQL Server's data directory and Attach the database in SSMS.
I am getting the following error whenever I am trying to open the db_name.mdf file:
The database '{path}\db_name.MDF' cannot be opened because it is version 706. This server supports version 662 and earlier. A downgrade path is not supported. Could not open new database 'db_name.MDF'. CREATE DATABASE is aborted. An attempt to attach an auto-named database for file {$path}\db_name.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Connection string as follows:
<add name="PasswordDBContext" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\db_name.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
I am working on a asp.net mvc 4 project within visual studio.
Any help to get the issue resolved are very much appreciated. Thanks.
LocalDB is a new feature introduced in SQL 2012 Express - you will need to install SQL 2012 Express LocalDb if you need to use an MDF in this manner.
Krzysztof Kozielczyk has blogged several entries around on LocalDB here - take note especially of the issues when running under 'Full IIS'.
IMO using LocalDb with ASP.NET is for a developer machine config only - i.e. when you are ready to deploy your (code first?) MVC 4 app to a testing or production environment, you should consider attaching ASPNETDB.MDF more permanently to a SQL Instance.
You cannot attach a MVC 4 localDB in SQL Server 2012 Management Studio. You'll need to connect directly.
Open up SQL Server 2012 Management Studio. You can download a free express version here:
http://www.microsoft.com/en-us/download/details.aspx?id=29062
During installation make sure you check the localDB component to be installed.
After installation, open Management Studio and the "Connect to Server" dialog will appear.
Enter (LocalDb)\v11.0 in the Server Name textbox. Use windows authentication and click connect.
Your asp database will show in the manager. You can then script it out to what ever you want and edit the DB and make the appropriate changes to your connection strings in your web config.
Remember that if you're using Code First, which in VS 2013's MVC Internet template uses, you'll need to check your db creation code in your app start folder.
LocalDB was created so you can create data driven web applications without the overhead of a full version of SQL server running on your development machine. When you deploy to a production server, migrate to a full SQL Server instance.
Hope this helps :)
Set your database connection string to your Locally installed DB is as below.
Web.config :
<add name="ContextName" connectionString="Data Source=ServerName;Initial Catalog=DBCatalogName;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
I'm developing a CMS and I'm using SQL Server with it. I want to automatically create my database in SQL Server 2008 when my app is installed.
I can generate a script. I'm wondering that there might be a way that I can install SQL script in a database using an MSI file.
e.g. in this link we can install database using a MSI file
http://www.microsoft.com/download/en/details.aspx?id=23654
I just wanna know how can we do it. Is it created using SQL Server or Visual Studio
you can attach a database through the app.config. in your installation you should copy this database to the right place.
Look here how to set your connection string:
http://www.connectionstrings.com/sql-server-2008
I'm having a bear of a time getting visual studio 2010 (ultimate I think) to properly attach to my database. It was moved from it's original spot to #MYAPP#/#MYAPP#.Web/App_Data/#MDF_FILE#.mdf. I have three instances of SQL Server running on this machine. I have tried to replace the old mdf file with my new one and cannot get the connectionstring right for it.
What I'm really trying to do is to just open a DB instance and run a DB create script. Then I can have a DB that was generated via my edmx (generate database from model) in Silverlight business application (c#)
Right now, when I go to Server Explorer in VS, choose add new connection, choose MS SQL Server Database File (SqlClient), choose my file location (app_data directory), use Windows authentication, and hit the Test Connection button, I get the following error:
Unable to open the physical file "". Operating system error 5: "5(Access Denied.)". An attempt to attach to an auto-named database for file"" failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
The mdf file was created on the same machine by
Connecting to (local) in SQL Server management studio.
Getting a new query.
Pasting in the SQL from the generated ddl file.
Adding CREATE DATABASE [NcrCarDatabase]; GO; before the pasted SQL and
Executing the query.
I then
Disconnected from the DB in Management Studio.
Closed Management Studio
Navigated to the DATA directory for that instance
Copied the mdf and ldf files to my application's app_data folder.
I am now trying to connect to the same file inside visual studio.
I hope that gives more clarity to my problems :).
Connection string is:
Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\SourceCode\NcrCarDatabase\NcrCarDatabase.Web\App_Data\NcrCarDatabase.mdf;Integrated
Security=True;Connect Timeout=30;User
Instance=True
I was getting "access denied" until I ran Visual Studio as an administrator. I then had to detach the database from MSSMS before I could get it into Visual Studio.
You mentioned that your MDF file was moved. Was the MDF properly attached to SQL Express after the move? See: How to: Attach a Database File to SQL Server Express.
Access denied might well mean that you already have an active instance that has opened the file prior to you doing it - and if you have three active instances, it is likely one of them that is the culprit.
You can try to connect to the different instances with Management Studio and see if you can find the base there. If yes, the detach it from the instance and re-try from Visual Studio. Or, if possible, try to shut down all three instances and then re-try from Visual Studio. If that works, restart the instances one by one to determine which of them is trying to get the file.
I've previously answered a similar question that might help.
Your Sql server service runs under a given account. You should determine the account through the service properties then change the db file security access to full access for that account.
Give Security to Full control for your application Folder and .mdf, .ldf files. Write click on the folder which contains .mdf,.ldf files
Go to property
click security in that
Click Full Control in allow.
and them proceed your process.
I am trying to learn Asp.net MVC framework. I was looking at the video tutorial at the link below
http://www.asp.net/learn/mvc-videos/video-395.aspx
In this video the very first step is to add a new database to the example application.
I have visual studio installed on my development machine but the SqlServer Express is running on a different machine, so when I try and add a new database following the same steps as the video I get the following error
"Connections to SQL Server files(*.mdf) require SQL express 2005 to funciton properly. Please verify the installation of the component or download from the url"
I am assuming this is because Visual studio is looking for an instance of SQL express on my local machine and since it doesnt exist on the local machine,it errors out.
So how do i tell visual studio, to connect to a different machine and create the database there?
I am using Visual studio 2008 with .net 3.5 Sp1
Make sure that remote connections is enabled in your sql server express installation (http://www.linglom.com/2007/08/31/enable-remote-connection-to-sql-server-2005-express/). Then take a look at www.connectionstrings.com for the various ways to connect to the sql server as appropriate for your environment. Then configure the connectionstrings section in web.config and reference that configuration target when connecting to the db.
Alternatively you might try using LINQ to SQL which will streamline some of these tasks (still need to enable remote connections and get an appropriate connection string defined...LINQ to SQL wizard for the rest).
Open the Server Explorer and add a new Data connection. Same thing as adding a new .mdf. You can use it just the same.
create the database on the remote computer(edit: IIRC, you can also create it within visual studio when you add the connection)
ensure that it allow remote connections
add the connection in database explorer
I'm not sure what's happening in that video, but if you for instance are going to use linq2sql, visual studio will add the connectionstring to web.config when you drag the tables into the .dbml :)
What you'll have to do is attach the mdf to the database server you have running on your separate machine, and then open up your server explorer and navigate to that particular machine and select the database from there.
I am not going to see the video so I can't tell you what step to change. But it should be easy enough to write a connection string (or get it off the web) that connects to a database on the remote computer and not your PC.
I am so used to writing my own connection strings that I don't even know of any option in VS that automates this.
Instead of add a new database to a remote machine as you indicated on your local machine, you can try to create the database on the remote machine firstly, and then connect to that remote database within your visual studio.