I have created a database with 8 tables in SQL Server Management Studio on Windows 7 as a non-admin user. In Visual Studio Express 2010 on the same user I am developing a WPF application that needs to access that database. However, the database file seems to be saved in C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA and I cannot access that file from Visual Studio's Add Connection feature. Although I do have the admin password, files from that directory cannot be added. When I try to add it (after supplying the admin password) I get this message:
You don't have permission to open this file.
Contact the file owner or an administrator to obtain permission.
Furthermore, during various stages of development I will need to create an .exe to send to a colleague for testing. Therefore, from what I understand the database needs to be included as a resource in the Visual Studio project. I have googled all day but found nothing relating to what I thought would be a common scenario. How can I add the database as a VS resource and access it from C#?
Thanks.
As a result of the comments....
SQL Express will provide you with the functionality that you require. Whilst it requires the machine to have the engine installed it does allow instance mode where you can directly attach database files in the connection string.
Additionally SQLExpress can be accessed via the MSSQL Management Studio tool (remember the default instance for this is .\SQLExpress
Related
When building an ASP.NET MVC Web Application on Visual Studio 2017 I select the option for individual user accounts for built-in register and login functionality. This tells me that it uses a SQL server database for user profiles. After registering a user I am struggling to find this database and the data in visual studio, I cannot find the SQL server database it was referring to when creating the project. Does anyone know where this database is stored as I need to use it for other functionality.
Take a look at the connection string (look in appsettings.json for a Core app, otherwise web.config)
you might see something like this: "Server=(localdb)\mssqllocaldb;Database=...."
To access this in SQL Server Management Studio, just enter (localdb)\mssqllocaldb as the server name and connect with Windows Authentication, then the Database referenced in the connection string will be accessible.
If you want to access this directly from Visual Studio, select View -> Server Explorer. Once this window is open, Select Connect to a Database. For the Data Source, select Microsoft SQL Server (SqlClient) and for Server Name Enter (localdb)\mssqllocaldb, now the database referenced in your connection string should be able to be selected under the Connect to a Database section.
It's worth noting the database may not be available if you have not run the initial migration.
This db is created at runtime... you will not see it after creating your project, you must run it at least once, add a user, and then the Entity framework will create the db structure.
I'm coding a C# Console Application that connects to a database and runs some queries where my database Engine is Microsoft SQL Server 2016 and I code in Visual Studio 2015. I have already installed and activated InstallShield Limited Edition on my visual studio and I'm able to make an installation(setup) file for my C# Console Application.
I don't want to to install Sql Server on my customer's PC and attach the database to that manually, instead I want to give everything in an installation file that includes .Net framework 4.5 and my database. The first part(.Net Framework) is done by InstallShield easily, but I don't know how to attach my database to the installation file.
Please explain how to do this and if any other version of InstallShield(Express, Professional or Premier) is needed let me know and explain the steps in that version.
Note that I want to give the installation file to the customer and make every feature of the app function well after he/she installs the program without needing to do anything manually.
Sql server 2016 cannot be installed automatically as it needs to be configured by the user, he must set the instance names, permissions and so on, which makes it unusable for your scenario.
What you need to use is Sql Server LocalDB, this is a subset of Sql Server Express for your concrete scenario, something which can be installed without the need of configuration and capable of attaching a database file also without user interaction.
You can find information about LocalDB here, as you see it can be downloaded as a .msi, in this way you can add this msi to your installshield project and chain it (more info on how to chain an installer here), it will not ask to the user about complex configurations, just a simple installer. To download the .msi you get the sql server express installer on your development machine and instruct it to download media and select the LocalDB package, that will give you the .msi.
Finally you will add the database file as part of your project files, then you only need to specify on the connection string the path to the file.
I want to create a setup file for an application that uses the following tools and technologies:
Microsoft visuals studio 2013
MSSQL server 2012
and I have used winforms and C# to write the program.
My questions are:
If I want to deliver the application to customer without giving out the source code what technique or tool should I use?
How do i supply the database? Should I detach it? How do I provide the database with my application?
I'm assuming you need to deploy the application you've created with Visual Studio rather than deploy Visual Studio itself. In which case you have a variety of options depending on its destination.
You can just copy your executable and required dependencies to a destination without distributing your source. However, there are several tools out there that will subsequently disassemble your assemblies to reveal the source.
The Visual Studio website has a list of options for deploying applications. If you want a tradional Next -> Next -> Finish type of installation, I would suggest using InstallShield Limited Edition.
For SQL deployment it would depend on the Edition you have used and whether the server already exists at the destination. Additionally, it will depend on whether you only need to deploy the schema or populate the database too.
You can distribute SQL Server Express with your application. SQL Server Management Studio will allow you to generate a "CREATE DATABASE" script (right-click database -> Script database as -> CREATE to -> File) from your existing database that can be executed as part of the installation. Alternatively, consider a backup/restore approach as detailed in this article.
I'm working on a website in visual studio for my senior project. I am trying to set up a login page for the website but since I have to be able to submit the finished project I was wondering if there was a way to set up the website administration tool to work anywhere.
i.e Is it possible to save/set up the sql server database that is used to login to the website on a flash drive where the entire project is stored? This way even if I open up the project on a different computer I will still be able to access all aspects of the project.
Any links to resources that I can scour would be greatly appreciated.
I am using Visual studio 2012 with asp.net 4.5
1.If you want a common database location which should be accessed by all, then you'd need to make certain that other machines have access to your local machine's database server
If you want the entire code plus the database to be present separately on each machine, then you'd need to share a database backup along with the application code folder and each machine would require the database backup to be restored on their database server along with setting up the application.
3.i can also prefer the Join me or VNC or any virtual tools to access your machine
Can't access Northwind database from Visual Studio
I am working on my own computer, and created tne Northwind database from a script file. i should be the admin on the computer
and can access the table from SQL Server
From windows explorer, I right click the table and I can see two accounts that have full control (full control, modify, read etc are all checked). those accounts are
SQLServerMSSQLUser$Gary-PC$Gary (Gary-PC\SQLServer..
Administrators (Gary-PC\Administrators).
However, when i select the table to try to connect to it in VS, i get the message, you do not have permissions to view this file.
is there something else I have to do in SQL server to set permissions? or might it have something to do with the user context not being one of these two users in visual studio?
I guess you mean the Server Explorer/Database Explorer in Visual Studio, When you add a connection in Server Explorer there is a field for user name and password, however the default is using Windows Authentication, if you don't use that you probably have to set your user id correctly there.
Server Explorer/Database Explorer can be access from the View menu, for the existing connection you need choose the modify menu.
Please note if you connect from your code, the connection string is set in your code .NET, C# or configuration not from the server explorer, you need to set them separatly.
I don't have the exact the same version of C# Express installed, the settings might vary a little on different versions.
The connection string in Database Explorer/Server Explorer is depending on the the data source you use. You might want to look at this to connect to SQL Server using Microsoft SQL Server(SqlClient)
Then you can see the SQL Server Authentication method from Visual Studio Express.
You may also need to change the SQL Server Authentication, That is in SQL Server Management Studio Object Explorer, right-click the server, and then click Properties. On the Security page, You can see Server authentication, MSDN has that well documented.