SSMS, Visual Studio, SQL Server - c#

Need Help please.
I have installed SSMS and Visual Studio.
I have 2 issues.
I am trying to learn SQL DBA and hence I installed SSMS only, I haven't installed SQL Server/Express.
While opening up a new query on SSMS, it asks me to enter the server name which I am unable to find and neither I can find instance name anywhere in my computer.
I have tried everywhere cmd and configuration manager.
Same with visual studio, when I try to create database, it doesn't allow me to add new local db as it doesn't show up when I try to add.

SQL Server is based on the client/server database system. SQL Server Management Studio is a management client, so you need a SQL Server installation in order to use it. You can install SQL Server Express for free which has a very similar feature-set to the paid editions (Standard and Enterprise Editions).
...in comparison to MS Access or SQLite which are a file-based database systems.
Visual Studio is an IDE which has some database tooling (SSDT: SQL Server Database Tools), while it can also be used for DBA tasks it is more appropriate for software development tasks using SQL Server than SSMS.

Related

Understand localDB is relation to SQL Server Express and SQL Server CE

I'm trying to understanding LocalDB by reading MSDN: SQL Server 2016 Express LocalDB and MSDN: SQL Server Express LocalDB and SQL Server Express and a number of SO posts including confusion about SQL Server Express and localdb, I still cannot understand what is LocalDB. I understand and have used SQL Server Express and SQL Server CE.
Questions:
LocalDB...the necessary SQL Server infrastructure is automatically
created and started
My understanding is that, if using LocalDB to handle an application's database, neither the developer nor the client machine where the application is deployed needs to install the heavy SQL Server Express, but just need to install the lighter LocalDB. How, then, without SQL Server Express install can localDB "create(d) and start(ed)" SQL Server? If localDB
... once installed, LocalDB is an instance of SQL Server Express that can create and open SQL Server databases. The system database files for the database are stored in the users' local AppData path which is normally hidden.
If developer or client can use localDB without installing SQL Server, how can localDB be an instance of something that is not installed? Or is localDB an incomplete version of SQL Server Express that just does not need to click..click..click.. to configure. Essentially localDB works like SQL Server CE where localDB use some hidden "files" in AppData to create database while SQL Server CE use the dll to generate the database?
SqlLocalDB.msi program to install the necessary files on the computer
If client still needs to install localDB (which is not really portable along with the application like SQL Server CE), then why not just install SQL Server Express? Either localDB or SQL Server Express is above 100MB+ anyway and need separate installation, what is the point of using localDB anyway?
LocalDB is a programmer-oriented version of SQL Server Express that needs to be installed just like SQL Server Express.
Unlike SQL Server Express, it's not installed as a Windows Service that starts up with your Windows OS - but it only starts up as needed (when your application starts up, or when you start it manually with the SqlLocalDb command line tool).
But LocalDB IS SQL Server Express (not Compact Edition). It uses the same .mdf and .ldf database files like and desktop/server version of SQL Server, not SQL Server CE's .sdf file format.
We used localdb on a project where we had agents in the field using laptops.
The functionality of localdb was better than SQL Server CE (I don't remember exactly what CE was missing, but it was important to the project), you should review the functional differences.
Another advantage was the db was stored in the user folder which makes it impossible for other non-admin users of the laptop to see. This allowed us to reuse and even share laptops between users without mixing data - a nice feature.
Finally, the dbs (with a little effort) can be copied to the dev/support side and restored/attached for troubleshooting. They are full .mdf/.ldf database files.
You do have to create the instances using a command line (sqllocaldb utility), after the product is installed. This was just part of our install app.

how to automatically create aspnetdb.mdf to store administration security data

i was trying the MVC Music Store project but i encountered a problem when going to the administration tool, it says
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Unable to connect to SQL Server database.
I searched online and tried numerous ways and found out it is because i don't have sqlserver express edition, so i can't use the AttachDbfile feature to auto create aspnetdb.msd file to store administration data
as i stated in the title, the truth is i installed sql server 2012 express first, but because i need reporting services i then installed the full sqlserver 2012, but i didn't create a new instance when installing instead i selected adding new feature to existing instance, so why does the VS say i don't have the express version now, i am totally buffled
does this mean if i want to use the app_data file feature again, i have to install sql server 2012 express as a new instance again?
SQL Server Express Edition is the only edition of SQL Server that supports User Instances. Thus, if you want to use a User Instance and do not have SQL Server Express Edition installed, you must install SQL Server Express Edition.
If you have a "full" version of SQL Server, I would suggest using the ASP.NET SQL Server Registration Tool (aspnet_regsql.exe) to create the equivalent of the aspnetdb.mdf database.
Edit:
As indicated in the answer to Can we install Express edition and Standard edition of SQL Server on same PC User?, it is possible to install both SQL Server Express Edition and a "full" version of SQL Server on the same computer.
However, it sounds like you performed an Edition Upgrade which replaced SQL Server Express Edition with the "full" version of SQL Server. If this is the case and you still want to use a User Instance, install SQL Server Express Edition again.
If you are not sure which edition(s) of SQL Server is installed, see How to determine the version and edition of SQL Server and its component.

Unable to connect to Sql Server Express database

I installed Sql Server Express 2008 R2, and created a database file in Sql Server management Studio. Now From Visual Studio 2008 I try to connect, but it fails with error:
Unable to open the physical file
"C:.....mdf". Operating system error
32: "32(The process cannot access the
file because it is being used by
another process.)". An attempt to
attach an auto-named database for file
C:....mdf failed. A database with the
same name exists, or specified file
cannot be opened, or it is located on
UNC share.
...This is first time I use Express. I only used Sql Compact Edition before. Are there some settings here I need to figure out? It's not a duplicate name of other connection, and I have closed management studio completely. Still this error. What am I missing..?
If there are some settings, please give a little detail how I access them, as I'm not used to dealing with databases.
SQL CE is a file based database - SQL Express isn't.
It is a SQL Server - you can add it using the Server Explorer in Visual Studio.
The instance name is normally .\SqlExpress.
I faced the same issue today, and guess what daemon tools was the reason for this problem, so if you have installed daemon tools uninstall it and then try again.
Hope it solves your problem too.
You do not want to be connecting using the mdf. What you want to do is Open a SqlClient.SqlConnection and then using the SqlClient.SqlCommand execute queries on the database, and then read the information using the SqlClient.DataReader, just like you would with A SqlCE database.
If you are trying to add it to the Server Explorer you just need to connect to the database just like you would in SSMS (Management Studio) and then you can use it in your project.
If you created a database in SQL Server, you probably have it attached. In Visual Studio you cannot access this database as a file. You have to access it as an attached database (i.e. by its name).
Generally you can use database in files as well in Express edition. If you for some reason want to use file directly, then go to Management studio, right click on your database and detach it. Then you can connect to it from Visual Studio on file basis.

Database connection fails

I have written c# application that uses mdf file for database.when i make setup of that project and runs on other computer having dotnetframework and sql server compact 3.5 then id dose not runs and exception is shown saying something sql server not found or not ready for connection something like that what should i do
mdf is not for sql server compact edition, it is for the real sql server. You need to deploy it to Sql Server Express edition or higher.
Edit:
You can install SQL server express edition or if you want to use the sql compact server you need to create a "local database" in visual studio.
When adding a mdf-database to your visual studio project is is attached to your local sql express database server behind the scenes when you start your project.

Is the "SQL Server 2005 Database Project" the thing I'm looking for in this use case?

Please refer to my previous question here:
Link Here
Will this project type be useful for installing the necesary database on a servers machine?
That is not what you want. That project type is for creating SQL Server CLR Integration objects.
You need to actually install SQL Server, the product, or SQL Server Express, on the server machine.
Edit: Actually this might not be entirely correct under all circumstances. If you have the Database Edition of Visual Studio then you have different SQL Server projects which are intended for deploying and upgrading databases. But they still won't install SQL Server for you - you (or your customer) will have to do that separately.

Categories