W
W
wolfak2015-05-21 21:52:55
SQL
wolfak, 2015-05-21 21:52:55

Queries to SQL Server in Visual Studio how to display result in WPF?

Hello. There is a ready base with tables and data on the local server SQL 2008 R2.
Successfully connected the database in Visual Studio 2013 and added the data source in the data source panel.
Interested in a detailed description or advice on how to perform simple database queries and display the result in a textBlock or other elements in WPF?
I used to work with PHP + MySQL, I thought there was a similar work with the database, but nothing came of it. I climbed a bunch of sites, but nothing helped.
Thanks a lot for your help.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sumor, 2015-05-21
@wolfak

Simple queries can simply be done via SqlConnection/SqlCommand.
SqlConnectionStringBuilder - set the database server, database, authentication type.
SqlConnection - join.
Create SqlCommand . You set either the text of the command, or the storage, along with the parameters.
Execute SqlCommand - or ExecuteNonQuery - if no response is required. ExecuteScalar - if one response. ExecuteReader - for reading results.
In the cycle you read - you lay it out where you need it.

R
Rikcon, 2015-05-21
@Rikcon

https://msdn.microsoft.com/en-us/library/ee340709%...
Something like this.

A
Artyom, 2015-05-25
@artem_b89

Hello.
To work with the database, I recommend using the Entity Framework, it is quite easy to learn, there is a lot of information on its use on the Internet, for example metanit.com/sharp/entityframework/index.php
For a WPF application, it is better to use the MVVM pattern, there is also a lot of information on its use, for example professorweb.ru/my/WPF/documents_WPF/level36/36_5.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question