Requires SQL Server 2012 Express LocalDB - c#

I have one problem that's causing more problems.
Let me explain what's going on:
For the past week, wanted to learn ASP.NET MVC and develop an app.
To get my machine ready, installed:
Visual Studio Enterprise 2017 32/64-bit (Multilanguage)
SQL Server 2016 Enterprise With Service Pack 1 64-bit (English)
So, after that, I thought to be good to go.
This is the app I'm using to do the learning: APP.
Then, once I open in Visual Studio, this is what happens first:
Didn't really understand this message. but my thought remained: how can I open using SQL Server 2016?
This "problem" quickly vanished with:
Ok, let's still try to do a build and see what goes on:
Cool, I'm able to see the app.
Well, now that I'm in a "lucky day", let's test to register:
This last error has to do with the protocols selected for the server.
It has to do with MS SQL Server configuration. Which means, I may need to install additional ODBC drivers for MS SQL.
How can I fix this and be able to register?
Note: If there's any info you might find important in order to understand how to help me with this problem, let me know. This because I'm a noob in the field, just getting started.
Here is the course I've been following.

You need to create a database in your SQL Server 2016 and then update your connection string to use that database.
Your connection string should look like
Server={server name},1433;Database=tiagoleft.music_shop.dbo;User ID={user id};Password={your_password_here};Trusted_Connection=False;E‌​ncrypt=True;Connecti‌​on Timeout=30;
Note: while installing, if you configured only windows authentication, then you have to update the connection string to use windows authentication. For that to work, replace the user id and password from the above string with
Integrated Security=True

Related

How to Run Windows Form Application with SQL Server Database on Another Computer

I'm using Visual Studio 2015 and I just created a Windows Forms application with a SQL Server database. I finished the program and tried to run the application on the other computer but it didn't run. I also tried to install .Net Framework v4.0 and SQL Server Express on that computer and also put the database in path C:\ so that the SqlConnection path on my computer to another computer will be the same.
The code is like this:
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
string connection = #"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Database1.mdf;Integrated Security=True";
But I got an error that is the database I placed in path C:\ is not writable whatsoever. I want to know what I can do in order to run the application.
You must install SQL Express on the computer/server where you want to have the database and then attach the MDF file.
Important:
- Remember to open port 1433 in the Windows Firewall.
- If you are going to use SQL Server authentication, you must create and / or activate the user with the desired password.
- To connect you can use the IP of the computer/server, preceded by the instance of sql express. Example: YourIP\SQLExpress
Good luck!
you need to create sharing server for database and after this, you can access your DB to anywhere and any computer
Thanks
So much misunderstanding and misinformation around LocalDB.
While it was being developed, your application was using an edition of SQL Server called LocalDB. This is a low admin lightweight edition that lets you reference the MDF file directly (contrary to some comments here)
When you deploy your app you decide whether you want to stick with LocalDB or upgrade to a more scaleable edition of SQL Server.
In your case, I suggest you stick with LocalDB
There's some background here and a link to a video if you have time
LocalDB deployment on client PC
https://blogs.msdn.microsoft.com/sqlexpress/2011/07/12/introducing-localdb-an-improved-sql-express/
Now if you really want to an answer you need to post the exact error message that you see, not a vague recollection of it.
The problem might be that LocaDB is not installed, or it might be that there is some SQL Server access issue. We can't tell because you did not post the error message

asp.net app on IIS can't connect to localdb

I have an asp.net web app running on IIS, and everything is fine, until I try to access the database I get this error:
I have read the 2 parts of the Using LocalDB with Full IIS: 1 Part | 2 Part
I followed the instructions and still get the error, is there a way to check that I have followed the steps correctly?
Is there anything else I can check for that may be causing this error?
Note: I tryed this with asp.net and asp.net core applications, the core one doesn't give any description at all so I am testing this with asp.net. The database that I am using is the one that visual studio provides. If you would like me to provide any further information ill be happy to, I have been stuck with this issue for a while now and can't seem to resolve it.
Turns it's not too complicated, but my inexperience with both IIS and Databases made it confusing. Hopefully this can help someone in the future. There might be some minor steps/tweaks I missed out but that's because the whole solution took a while to setup.
Make sure you have SQL Server actually installed. You can download the 2008 version which I used here. Can be a pain to setup and I actually messed up when installing, here is the vid I watched (I didn't install: Database Engine Services).
Next you want to make sure the IIS identity (IIS APPPOOL\ASP.NET v4.0 in my case) has permission to connect to the Database server. Check the answer here.
Once it has connected to the database server, it need's to be able to connect to a database on the server (I didn't know that a database and a database server are 2 different things). You need to do something simular to Step 2, in SSMS expand the databases folder, and select the database you which to grant access too, there is a security folder in there as well and you want to add the Identity to that folder.
Other useful points:
If your sql configuration manager isn't opening please tell it to, thank you gofr1. This is a very useful tool for checking up on your database connection (as it turns out)
Make sure you setup your connectionString to point to the sql server. Make sure it doesn't connect to the mdf file with AttachDbFilename=|DataDirectory|\your_database_name_here.mdf located in the connectionString.
For asp.net Core read the documentation it is god, as the errors are non-existent once the app is deployed on IIS it will help in dark times. Always check publishOptions.
To further help you understand how the whole process works, thank you to gofr1
read here. Didn't solve the issue but worth a read.
Might include more stuff in here later if I remember I missed anything out.

How to use database without installing it?

I have a database in SQL Server 2008. I want to deploy my software with CD.
I want to give end user 2 choices :Use from CD and install it.
When end user selects the "Use from CD", I don't want install program.
How can I do program execution without installing?
Please help me about this problem
Thank you for your attention.
The program is coded In C# in MS visual studio 2010.Database Management system is MS Sql Server 2008
Use an embedded database which requires no setup and in-process execution, in your case best option is probably SQL Server Compact Edition
Edit: I know there are also other alternatives like BrekleyDb or SQLite but since Atayi is using SQL Server right now for his database, I suggested SQL Server Compact Edition to avoid any issue and stay on essentially the same technology/platform.
Please help me about this problem
Don't use the technology you selected.
This is like saying "I want to drive a ferrari, but one that uses no fuel". Engines use fuel. SQL Server requires installation.
Alternative is SQL Server CE which you can load into the process.
THat is it. Run from CD is not possible without having SQL Server installed if you use SQL Server. Arguing wont change that.
First of all, I don't know if SQL Server '08 exists as a portable version, but if it burned on a cd, the use of a database is not there. The burned files cannot be changed :-)
A portable DBMS is SQLLite, there are bindings for C# :-)
You can "Silent Install " Sql server also, that way the client will not be bothered by the configuration of the server.
When running from CD - change database back-end - use simple Microsoft Access Db file with ADO ODBC connection. In such case - you will have almost same SQL language and no need to install something for access db (huh, maybe general odbc drivers if they not exists).
When running from HD - switch db backend to full-scale MS SQL server ...

First time using security in ASP.NET

I have to do a homework where i have to implement user registration and login in ASP.NET.(Form-Based)
I am reading my book and it says that the first thing I should do is use aspnet_regsql.exe to configure, but when I went to pick the the database I get this error:
I keep trying to fix this problem, but I dont know how.
At this link I found a note that says:
The database elements that are
installed in the feature database will
always be owned by the SQL Server
database owner account (dbo). In order
to install the feature database, a SQL
Server login must be permitted to the
db_ddladmin and dd_securityadmin roles
for the SQL Server database. However,
you do not need to be a system
administrator for the SQL Server in
order to install the feature database.
I don't understand what I am missing.
-What should I do?
-Where can I find db_ddladmin and dd_securityadmin?
UPDATE
As the above step looks like is not able to find the database, i thought i better create it manually. so this is what i do
Step 1:
Step 2:
Why is this happening?
I just need to prepare my work enviroment to use form-based authentification. I cannot do my homework if i cant configure my working enviroment first. Can someone give me a hand to fix this? Does it have to do something with permisions or other?
You are getting the error because you're trying to connect to a server that doesn't exist. If you are using sql server express, your server name would be creator-PC/SQLEXPRESS.
I believe I remember having to do this too. http://support.microsoft.com/kb/914277. Follow the instructions under "Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition"
First thing you need to do is try to browse to the database itself. I use the sql server management studio to do this. If you are able to connect, then you will need to edit the user permissions, otherwise you probably have an issue with the sql server setup.
if you tried connecting using management studio to your DB server and if you are able to connect but you are not able to connect through asp.net application then there is a probability that the database does not have any permission for aspnet user so first create a new user in sql server for aspnet user and try again to connect using the wizard.
Generally the error comes when you not have your server started or installed on machine. Also Make sure the server instance is running and you place the right name of the server instance. if your sql server is configured to use sql server authentication then provide proper parameters i hope this all will help and get you out of it

using MySQL with C#

I want to know if it is possible to use MySQL Engine without having to install WAMP Server. I'm developing an application that will require a database, so I was thinking of using MySQL instead of MS SQL or access. So I don't want to install the WAMP package yet I want to install the MySQL Engine, so if possible, please provide me with the download link for the MySQL and how to install and use (start/stop service).
You will need the runtime and the .net connector to make this happen. You also might find the workbench (gui tools to manage the server and run queries) to be helpful.
The runtime installs a service by default, which you can control on the commandline or via the windows service management console (services.msc).
This sounds to me a lot like you're thinking 'desktop application', where the MySQL database will be a simple local data store. If that's the case, MySQL is not a good choice.
MySQL is a server-class database engine. It's designed to run full time in the background as a service. This makes it overkill for a simple desktop app, and as a user I'd be mad if your simple desktop app required me to run the MySQL service.
For the kind of app I think you're building, you really want an in-process or desktop-class database. Good examples include SQLite, SQL Server Compact Edition (not Express), or even MS Access. Any of those would be a better option here than MySQL.
On the other hand, if I'm wrong and you're building a web app or an app that will be distributed to several computers that all share the same database, then MySQL is a perfectly fine choice and you should read #Femaref's answer.
If your database isn't going to be incredibly large you could go with SQL Compact. It comes with the .NET framework, and works well for smaller databases.

Categories