Hi Guys,
I’ve got a really good idea for a service I’d like to create for the web, but since I’m new to ASP.NET I’d like to get everything up and running before I go and buy hosting etc.
What I’m curious about is the database side of things.
I don’t quite understand how I can create a datebase on my computer for the sake of testing and practicing (Presumably through mssql server) and then just transfer it to a hosting account when I’m ready.
I don’t want to end up re-writing code if I can help it.
I guess the main part I don’t understand is how can I connect to a database on my computer via my application and then change the connection so that it points to the web version when I’m ready.
I know that when you create the database and include it in your project it’s not technically inside your project (Right?), but it just seems that the application is very rigid once you’ve specified the connection.
If anyone could help me get a better understanding of this I’d very much appreciate it.
I’ve googled around, and gone through a few books, but none seem to clearly answer the question I have in mind.
Oh and a secondary question, webforms or MCV?
I’m familiar with html, css and javascript, but I’m starting with webforms as I hear it’s easier. Should I make the switch or wait until I’m comfortable with webforms first?
MVC is a design pattern. There is no special way to code using MVC.
Typically MVC structures have three components:
A model which is business logic and associated data needed to drive the logic.
a view, which is the HTML and interface elements used to display your model. typically you will have some small amounts of logic such as conditionals or loops to display your data on the screen
a controller. This is a set of mappings that connect your model and view together with a URL.
Now, I’m not sure how it laid out in .net as I only switched from j2ee a short time ago, but when I was operating in spring (j2ee) it was the following
.java file for the model and controller
.ftl (freemarker template) for the view
so im pretty sure it would be .cs files for the controller and model and an .aspx file for the view. Feel free to correct me if I’m wrong as I use webforms and Strategy patterns.
No; it is merely for replicating structure and/or data.
Personally I use the Visual Studio Database Professionals GDR2 for documenting and refactoring a database. I suspect some redgate tools will do the job.
Their is no reason to read a technical book on how to solve this problem. Use SQL Server Publishing Wizard, as mentioned above, it is there for a reason. No need to over complicate it.
I advise looking up on some teaching books. I have the sitepoint book on building asp.net websites. it goes through database creation, connections and more. very good and it explains it all in plain english.
I am at the moment learning asp.net witn c# and it has helped me alot.
Thanks for the responses guys, that really helped to clear a few things up.
I didn’t expect so many tool recommendations, which was very welcome (Though I’ll probably stick with the free ones until I get more confident).
So I can quite happily build a database on my computer, connect to it, do whatever I like, then run a sql command (With the assistance of the suggested tools) and run that on the live server when I’m ready.
So how would you recommend I go about building my database?
Directly in mssql server express edition?
You mentioned doing it though visual studio, but I’m not sure how to go about this, where should I begin?
Any other recommendations?
Also, regarding webforms vs mvc, am I correct in understanding that mvc is more difficult, or are they of equal difficulty? (and I will be starting the project from scratch if that helps).
Well, creating the database using the server manager in VS is not adding for the project. Its just a tool to create a database.
What you want to do is create a database with tables, etc. The connection string should be saved in the web.config. Then when you go live, all you do is change the connection string to connect to the live database.
SQL Server Publishing Wizard. Look it up. It is now also part of SQL Server management studio and Visual Studio. Basically you can generate a huge SQL file which - when executed at the remote server - creates all structure and data.
Depends on the app here. Some stuff I’ll use redgate or Sql Management studio to generate scripts. Longer-running stuff, I use one of a number of migration tools to migrate the database to the proper version.