I've created a small ASP.NET MVC application and used a SQL Server database. I saw that the database was not moved to the Solution folder, so if understood correctly, the application won't work on other computers/servers.
Is it possible to move somehow the database to the project without losing the connection with the application?
Please help! Thanks in advance!
Answer:
The problem was solved with the solution from
https://www.codeproject.com/Questions/441590/How-to-add-existing-database-in-app-data-folder-in
No. Seriously. ANY serious setup will have a database server and somone will apply a backup of the database you provide there. Unless you write toy applications, you NEVER employ the databsae on the same machine and "in the folder" - this works for development, it is not how SQL is deployed in the real world of larger controlled applications.
And get used on how to make upgrades to that database via some sort of change script mechanism.
Related
I'm developing a WPF desktop application, and the database currently resides in SQL Server Express 2012. The app is undergoing acceptance testing, and periodically I have to backup my database and restore it on the tester's PC. This is setting alarm bells ringing that distribution is going to be a pain when we come to start working with customers - I don't like the idea of them having to use SSMS.
I wondered if there was any way to distribute the mdf file and have my application connect to that "directly"? I've seen examples of connection strings that specify an MDF file/path, and wondered if it was really that simple or does it still need attaching in SSMS first? (I'm guessing so, otherwise how would you configure things like users and roles?).
Most applications I've encountered run SQL CREATE scripts during the installation process. I'd prefer that way, because when you will have to change your schema some time in the future (and you will), you will have to do something similar, because you cannot exchange the old MDF (with your users' data) against an empty updated one.
this is my problem:
When working in webmatrix, if I have a published Umbraco site and I need to re-publish it to update the live version to my local version and I need to update the database too, I can't.
Webmatrix will say that the database file is in use. Of course it's in use, 'cause IIS is running on the server, and the site is live, so it's using its database, and it can't be overwritten.
What bugs me the most is that I haven't found any way to overcome this problem, if not by stopping my website's application pool on my server, or restarting the IIS service, but that's too much fuss!
There's got to be a simple way to update the database from Webmatrix.
I usually use a SQL CE database for my Umbraco websites but I can switch if SQL Server is needed.
Please, this is driving me nuts, I hope it's possible and someone will show me the way!
Thanks in advance
You could use the app_offline.htm method outlined here. Basically you can add a file to the root of the website called app_offline.htm and this will allow you to update the database. Obviously, you can format the app_offline.htm page to look like your site and have a some copy stating the site will be back up in a few minutes etc.
On a different note, moving the database to SQL Server causes a similar issue in that, although you can update the db without having to detach it, you still have to prevent people from accessing the site whilst the update is occurring.
I'm having trouble figuring out databases in VB.NET. (VS 2008)
What control(s) do I need to use and how do I use them? I am ,looking for tutorials and sample code too.
I'm working on a trivia game where the admin can remove and add questions to a database.
EDIT:
The program must be able to do all of the DB interactions itself through code.
Regarding DB portability...
I do not intend to install it on many machines, so portability is not a major issue, but I's rather not be bound to Access or SQL Server. (Is that possible? - A portable database file?)
A bit more complaining...
I really need help with connection strings and the whole DB gamut in VB. I've done DBs in PHP so I'm not completely ignorant. It's the VB side of things that's confusing.
Thanks.
Have you considered SQLite DB? It's a very small DB and is used my many vendors. I have not used SQLite personally, but I do know that Firefox uses it and so does iPhone (from what i've read).
SQLite does not require you to install anything (as per the post below). It's a nice alternative to Access or carrying around SQL Server Express.
If you do decide to use SQL Server Express, you will be required to install the run-time, from here for each machine it's used on.
Below are some links which may help you get started
Google for SQLite DB
ADO.NET 2.0 Provider for SQLite
And finally, here's a blog post outlining how to get it done, and quickly.
Cheers!
I would suggest Microsoft's Enterprise Library - The hands on labs available make it a breeze to setup access to a database, and can make it as simple as a config change to point to a new/different DB.
Also, check out http://connectionstrings.com/ for related info.
I have been working on VB6 database desktop programming, but now a client is asking for a
simple web interface (some inserts into SQL Server db used by a desktop application).
The question is: Which approach is better?
1)creating asp.net project, connected directly to the SQL Server database;
2)creating separate (simple) mysql database managed by php and synchronization (in 15 minutes for example)
Thanks.
Personally since you already have the SQL Server database, I see no reason whatsoever to add the complexity of another database and then synchonization. The first alternative is simpler to create and can be secure if you design it correctly. The issue about hosting is irrelevant since you are going to your own database that already exists, so is the issue about cost since the databse is already there. Further since you are already supporting SQL Server, you may be able to reuse some code rather than write new code (mysql's version of SQL is not the same as SQl Server's version). Synching the two databases may be more complex than you think (differnt data types, etc.) and the data in the real database is not real-time whereas with the first alternative it is.
I'd prefer the separate database approach.
It's more secure.
PHP/Mysql hosting is widespread
You can pretty much achieve anything with the technologies available, it just depends on your skill and productivity with specific technologies and the availability of online help. Plus Microsoft stuff you tend to have to pay for whereas PHP/MySQL is totally free.
I've recently inherited a database driven e-commerce site written in C# ASP.Net, with an MS SQL database.
I have had little or no experience with this exact type of application up to this point, although I am comfortable exploring code, and am familiar with SQL query structure and C# (and web mark-up languages too).
So far I've been able to make all the adjustments I've wanted to to the application, have debugged some stuff, removed some compiler errors, added a few new simple functions, and am enjoying myself rather.
I am experiencing some problems with displaying the information from the database within Visual Web Developer 2008 Express Edition.
Having faced initial setup problems with the web.config file I'm a little wary about the next steps to take!
I currently have a local copy of web.config, which connects to a local copy of the database during development.
When I compile and upload any new versions of the application, I exclude the local version of web.config, so that the remote version uses it's own web.config file to connect to the remote database.
In order to see any of the database information on the web pages during development , I have to run the website in the browser.
Should I be able to see this info in Design View in VS by creating a connection to the database in the database explorer? Will this affect the application when it is running remotely on the webserver? (as the connection would have been made to the local database and not the remote one, and hence the connection string would be different)
All of the DataGrids are blank in VS design view. If I choose a Data Source for them using the Smart Tags in design view, will they use the right Data Source when running remotely? Should I drop the local copy of the database altogether? Connecting to the remote database during development seems rather dangerous to me!
I hope this is clear, any and all help/links/pointers welcome!
Using different Web.config in development and production environment to learn how you can use different configs
Also check Scott's tip, http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx (Not sure if it applies to Visual Web Developer)