I am writing a console application using .NET 5, and I am using a LocalDB instance (at least I hope that's the right terminology) to store the data that the application needs. I can see the database (including both tables and all the data in said tables) in both the Server Explorer and SQL Server Object Explorer tabs of Visual Studio 2019, but the Data Sources tab the only thing that shows is the text "This window is not supported for the selected project."
The problem is, all the tutorials I've been able to find rely on that Data Sources tab. From looking at other questions here on Stack Overflow, it looks to me like that tab is deprecated with .NET 5? Am I correct? And how would I write the code to access the database and perform CRUD operations without the Data Sources tab?
Sorry if this is a stupid question; this is my first time using LocalDB.
You should use SQL Server Object Explorer. If you right click on the database that you want to connect, you can see the properties, including connection string. If you have trouble with incorporating Connection string into your code - you need to show the code and the problem.
Whether Data Sources is deprecated or not, as you can see it is not supported for most projects (I think it's just for Windows projects - but I may be wrong). Anyway - you don't need it. And by the way - this approach works regardless of the database you use (LocalDB, SQL Express or regular SQL Server)
Related
I have a problem with a data migration. I will try to give all the information to help me solve this situation. A little of history:
In 2005 an internal website was developed to help manage its business. Due to the latency and change of business rules a developer was hired in 2019 to put "order in the house" (me). When I got the website I was not given the source code, without thinking twice I performed a platform from scratch in C#. All right here, everything was a success. The problem then arose in data migration.
The most important thing to keep, was the files (pdf, .xsd, etc). I then picked up the data from SQL Server 2005 (old website) to SQL Server 2017 (new website).
The content of the files on the old website was in the data type of 'IMAGE' and after research I found it better to put in the new website as 'VARBINARY'.
With the data all migrated, on the new website when I have downloaded the file I get the following error message:
Adobe Acrobat Reader could not open 'file_name' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)
I do not know if it helps but for example, if I insert a file normally on the website its download works correctly. The field is that it behaves differently (the first was the one inserted by the website and the others came from the migration).
This is a print screen of database:
http://prntscr.com/mwilex
Does anyone know why the error? Has anyone ever come across a similar situation?
Bst: I run a query [SELECT SERVERPROPERTY('Collation')] and the output of the two Databases are the same, 'SQL_Latin1_General_CP1_CI_AS'
How to embed a database to a WPF application?
scenario: this is our school project and we are required to create a
system with a database. now, i have done the fundamentals (create a
database, creating a layout and the c# code for programability) but
now, when we are to transfer the build onto a different computer, the
database seems to be lost.
I'm using Visual Studio 2015 with SQL Server for its database and that database is placed within the localdb of my computer. what i want is a portable system so that we can present the system anywhere without the hassle of bringing my desktop to school.
thanks in advance <3
EDIT: there are a ton of ways to connect a database to a wpf
application and i dont know what to choose. theres the ling-to-sql,
entity framework, data source etc. which of these methods will be the
best way for a portable application with the database in it.
my WPF app uses SQL Compact + Entity Framework (code first) + migrations, yo can find sources here https://github.com/tym32167/arma3beclient
All database-related things placed in this project https://github.com/tym32167/arma3beclient/tree/master/src/Arma3BE.Client.Libs
Data context here https://github.com/tym32167/arma3beclient/blob/master/src/Arma3BE.Client.Libs/Context/Arma3BEClientContext.cs
Migrations here https://github.com/tym32167/arma3beclient/tree/master/src/Arma3BE.Client.Libs/Migrations
I'm busy writing a small app and I only want a database to load small amounts of data, in other words I don't need the functionality of SQL.
So I've installed filehelpers, but it seems very limited in the sense that I can read/write and even append data, but it seem impossible to delete one row of data in a table?
Does anyone know how to do this with filehelpers or point me to a different solution where I can just add a local db to my app without any other external software required?
PS. My visual studio does not have the "create local db" from the item selection.
For something like this, I'd use an embedded SQLite database. It gives you the best of both worlds, one file database for local data and most of the features of SQL.
See here: https://sqlite.org/
On their download page, they have lots of stuff and a plugin for VS:
https://sqlite.org/download.html
This is coming from a 15 year veteran of Delphi who has taken a State Job where Visual Studio 2010 C# is used.
So how do I see data at design time? It seems to elude me. At least it does not seem possible on the surface.
TIA...
You can use SQL Server Object Explorer or Server Explorer to view or modify database structure and data at design time.
Here is a good article series about SSDT (SQL Server Data Tools) which in linked article trains working with SQL Server Object Explorer.
I am developing an application in SQL Server using C#.
My database version is SQL Server 2005 Express edition, and .Net framework 2.0.
I want to make an updatable application.
e.g. whenever I do some changes in my application, then it should be available to update in all locations (like update in Mozilla Firefox).
But I also want that if I change some columns/stored procedures of the database, then those changes should be also updatable.
Please guide me how can I make that kind of setup.
Do you have any server or network share where you can distribute your application from?
If so, then you should take a look at ClickOnce which is available in any version of visual studio. it will automatically update the client each time you publish a new version. http://msdn.microsoft.com/en-us/library/t71a733d%28v=vs.80%29.aspx
As for the SQL updates, I'm not sure what you're asking for? if you use one database for many clients, then the only thing you will have to update is the client code which works with the database. in which case you will do the same thing as with any client update.
If you're having multiple instances of the database, you'll have to update each of them manually. You'll really want to keep track of each change you've made or use a comparsion tool for that. I'm using Red Gate SQL Compare, but I assume that there are also free tools.
First you need to decide on a setup tool which will create an EXE or MSI installer for your application. Perhaps this list will help: http://en.wikipedia.org/wiki/List_of_installation_software
After that, you can integrate an updater application into that installer. Here is a post with more details: What is the best way to auto update a windows application?
An installer takes care of the distribution and the updater takes care of your application updates.