Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello, i want to use sql server in my application. i.e, i need a database with security(username and password but i don,t know how to archieve that because i don't want to use localdb. Pls, help
Posted
Comments
[no name] 1-Aug-15 16:20pm    
You might want to update your "question" with non-contradictory information. You say you don't want to use localdb but then are using it but don't know how to copy paste a file. Think for a bit about what it is that you want to do, then explain that to us and you might get a meaningful answer instead of all of this confusing back and forth trying to get you to tell us what the problem is.

Although this article of mine is not about ASP.NET, but it gives you an overview of connecting to SQL Server using C#. How to connect SQL Database to your C# program, beginner's tutorial[^]. You should consider learning a few concepts for SqlClient[^] namespace first, generally, it is this class that is used to connect to and execute commands on SQL Server. SqlConnection, SqlCommand, SqlParameter and many more are objects declared in this namespace.

Chances are that you will be able to write your own connectors to connect to SQL Server and execute your own statements. In ASP.NET, Entity Framework is a good framework to work with SQL Server, EF allows you to focus on your logic and abstract the data manipulation layer and leave it to .NET framework. Read Solution 1 by Mika for that.

Edit

Since you are developing the application, it is good to use localDb rather than purchasing a SQL Server license and installing an entire server to run it. You should understand that even running SQL Server Express requires you to install the server, without it, your database won't work. LocalDB is a very compact edition (just as a personal tip, I think that SQL Server CE was upgraded to SQL Server LocalDB, because Microsoft is no longer publishing SQL Server CE officially), and LocalDB comes shipped with a few required files and assemblies (just similar to SQL Server CE) which are needed to run your database.

Then, on the hosting environment you can create a database there. IMO, it is better to create a new copy of database on their server rather than deploying your database files there. Many problems of authentication and similar raise when you try to deploy your application on server.

For these reasons, I would suggest that you continue programming and development with LocalDB, and when your web application gets deployed on hosting environment, you should run a script to generate a database file based on the environment. :-)

For more on LocalDB, read this[^]. I enjoy SQL Server LocalDB, after Microsoft stopped support for SQL Server CE. They save a lot of time and I don't even have to run any background server to get the data.

You should also note that hosting providers usually do not support LocalDB, they provide you with a licensed copy of either SQL Server 2008-2014.

How would I upload the database? As I said, you should not. You are not sure of what assemblies you will be provided on hosting environment. For this sake, I said create a new database on the server end when you upload your files there. Do that manually or by script.

As Mika has mentioned, LocalDB is not intended for commercial use you would require to get a copy of SQL Server, but a better choice is to search for a copy of SQL Server on the hosting server. Other features, such as advertising, payment processing is a totally different thing to talk about. :-)
 
Share this answer
 
v2
Comments
Thanks7872 1-Aug-15 12:34pm    
No. This doesn't answer the question. All these has nothing to do with the question. OP is just confused about where to have his db.
Afzaal Ahmad Zeeshan 1-Aug-15 12:37pm    
Maybe I missed something, but where did he say something next to "where is db". :)
Thanks7872 1-Aug-15 13:24pm    
Look at the last comment OP made in previous solution. It answers your query better.
Wendelius 1-Aug-15 16:57pm    
You're right, the OP is actually wondering where to put the data.

However, based on the information that was available at the moment when Afzaal Ahmad Zeeshan answered (basically only the original question), I see no problem in the answer.

Just my 2c.
Afzaal Ahmad Zeeshan 2-Aug-15 3:54am    
Thank you for standing up for me while I was out, Mika. I have indeed updated the answer with a little more explanation of what should he do. Do give it a quick read though. :-)
There are a lot of tutorials available depending on your needs. For example:
- Using SqlClient classes Beginners guide to accessing SQL Server through C#[^]
- Entity Framework with MVC Getting Started with Entity Framework 6 Code First using MVC 5[^]
- and simply EF Entity Framework Tutorials[^]
 
Share this answer
 
Comments
[no name] 1-Aug-15 10:09am    
I am not talking about learning to code. I know how to do those but its with localdb. And as it is, localdb is not secure and cannot be pushed into production. I have created an application with models but no database because i dont want to use localdb. I tink u get my point
Wendelius 1-Aug-15 10:20am    
I don't quite understand your question. If you want to use full SQL Server instance then install it on a server hand modify the connection string for the SqlConnection to point to the centralized SQL Server database. If you use EF then modify the configuration file to contain correct connection string...
Thanks7872 1-Aug-15 12:32pm    
Then provide credentials of the server where you want to host the db. All you need to do is to make change in connectionstring.
[no name] 1-Aug-15 13:21pm    
I'm sorry for the misundestanding. Please, correct me if i am wrong. For example, i need a secure database, then i start to code with the default database(localdb). Then when i am tru with the application, i then upload it to a hosting website. How will i upload the localdb to the host server. (also securing the database)
Wendelius 1-Aug-15 13:55pm    
I'm sorry but I don't still understand. Localdb is meant for single user applications with local data store without transactions. Other versions of SQL Server offer centralized database for multi user purposes.

For example when I develop SQL Server applications I always install the SQL Server edition I want to use in the end and develop using that edition. Each edition behaves a bit differently so for example starting with localdb and then switching to standard edition may cause side-effects to your program (consider for example the transactions).

Then about the hosting web sites, are you talking about Azure? If that is the case, I would make the development using it from the beginning, again there are differences....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900