How to Connect to and Modify a SQL Server Database with C WPFLINQ
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=nHxKc2WTcQI
In this video I show how to connect to and modify a SQL Server Database table through a WPF C# application. • I use SQL Server Express 2014 and Visual Studio Community Edition 2015 here, but I've used other versions in the past and its been the same. • C# Code: • using System.Windows; • namespace ExampleApplication • { • public partial class MainWindow : Window • { • ExampleLINQtoSQLClassDataContext dc = new ExampleLINQtoSQLClassDataContext( • Properties.Settings.Default.ExampleDatabaseConnectionString); • public MainWindow() • { • InitializeComponent(); • if (dc.DatabaseExists()) ExampleDatagrid.ItemsSource = dc.NewTables; • } • private void SaveButton_Click(object sender, RoutedEventArgs e) • { • dc.SubmitChanges(); • } • } • } • The XAML Code (replace the braces with angle-brackets, YouTube doesn't allow the angle brackets in the description): • {Window x:Class= ExampleApplication.MainWindow • xmlns= http://schemas.microsoft.com/winfx/20... • xmlns:x= http://schemas.microsoft.com/winfx/20... • xmlns:d= http://schemas.microsoft.com/expressi... • xmlns:mc= http://schemas.openxmlformats.org/mar... • xmlns:local= clr-namespace:ExampleApplication • mc:Ignorable= d • Title= MainWindow Height= 350 Width= 525 } • {Grid} • {DataGrid Name= ExampleDatagrid Margin= 0,0,0,33 }{/DataGrid} • {Button Name= SaveButton Click= SaveButton_Click Content= Save Margin= 0,286,0,0 }{/Button} • {/Grid} • {/Window}
#############################
