MainPage.xaml
<Window x:Class="ConnectionToSql.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBox x:Name="string1" Height="24" Width="150" Margin="70,10,0,0" 
                 VerticalAlignment="Top" HorizontalAlignment="Left">
        </TextBox>
    </Grid>
</Window>
MainPage.xaml.cs
System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient; 

namespace ConnectionToSql
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            SqlConnection myConnection = new SqlConnection(
                                            "user id=hanka;" +
                                            "password=;" + 
                                            "server=hanka-pc;" +
                                            "Trusted_Connection=yes;" +
                                            "database=database_systems;" +
                                            "connection timeout=30");

            try
            {
                myConnection.Open();

                try
                {
                    SqlDataReader myReader = null;
                    SqlCommand myCommand = new SqlCommand("select * from Vendor where V_Code = 21225", myConnection);
                    
                    myReader = myCommand.ExecuteReader();
                    while (myReader.Read())
                    {
                        string1.Text = Convert.ToString(myReader["V_Name"]); 

                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            try
            {
                myConnection.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

        }
    }
}