how to automatically create aspnetdb.mdf to store administration security data - c#

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.

Related

SSMS, Visual Studio, SQL Server

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.

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.

Service based database vs SQL Server Compact vs LocalDB?

My goal is to create a stand-alone C# Windows form application with 2-3 tables that will be installed on client machine with a installer file. And I don't want to install SQL Server 2008 software on client machine, I'm using Visual Studio 2013 C# for development.
My options are SQL Server Compct 4.0 but I don't see Visual Studio 2013 has inbuilt support for that, when I add new item to project I don't see Compact (.sdf) file option there.
I've installed third-party SQL Server Compact Toolbox so I can create .sdf file and connectivity but I believe Microsoft is not giving support for compact db now.
I can see service-based database (.mdf) file which is actually a LocalDb\\ something.
So what should I use if I don't want to install SQL Server 2008 on client but want to have db
at client software?
You should mostly base your choice on your target platforms and the level of SQL Server functionality you expect.
Target Platforms:
LocalDB does not support older versions of Windows (e.g. Windows XP) or WoW. Toad World's LocalDB overview has a good breakdown of its target-platform restrictions.
SQL Server Compact Edition has very few target-platform restrictions. Check out its download page under "System Requirements" for specifics.
Functionality:
LocalDB better approximates SQL Server Express functionally. SQL Server Compact Edition has many functional limitations (e.g. no support for stored procedures).
MSDN's introductory overview of LocalDB explains many of the important functional differences between LocalDB and SQL Server Compact Edition; and the aforementioned Toad World LocalDB overview explains some of what (not) to expect from LocalDB functionally too.
Redistribution:
Both SQL Server Compact Edition (per the "Additional Information" section of its download page) and LocalDB (per SQL Server forums) are freely redistributable: so you should be okay with either with respect to fine print.
maybe SQLite would be an option? check out: http://www.sqlite.org/
it's just a DLL/Assembly you need to reference and it's pretty straightforward..

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.

Can I deploy SQL Server Express with my desktop application just like builtin database?

Can I deploy SQL Server Express with my desktop application just like builtin database?
Because I don't want my client to set up separately SQL Server Express! Is it easy to integrate SQL Server Express into my desktop application ?
From the FAQ:
Can I redistribute SQL Express?
SQL Server Express will be free to use
and redistribute. The only
requirement that we have is that you
register to redistribute the product.
The reason we require registration for
redistribution is that we want to
ensure that we can get critical
security/product information to
ISVs/partners if necessary.
-Euan Garden
Product Unit Manager
SQL Server Tools
Take a look on how to do it:
How to deploy SQL Server 2008 Express as a prerequisite with ClickOnce
ClickOnce Deployment: Customizing SQL Server Express
How To Install Sql Server Express In Package Deployment With Different Instance Name
As said by MS:
"To obtain rights to redistribute SQL Server 2005 Express Edition, you must register with Microsoft. "
The link is: http://www.microsoft.com/sqlserver/2005/en/us/express-redistribute.aspx
Hope this will help.
By the way, you may be interested in MS SQL Server Compact : http://www.microsoft.com/Sqlserver/2005/en/us/compact.aspx
It's embedded dbms. It's free but also need a distribution rights registration:
http://www.microsoft.com/sqlserver/2005/en/us/compact-redistribute.aspx

Categories