ClientServerWebSol Week11

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Week – 11 – Topics:-

4. Develop integrated data-driven applications


such using SQL Server and UWP.

4.1. Develop a client system to use a database and


SQL commands.

4.2. Design and use a Business Data Layer to


communicate between client and server.
Add a connection string
In the App.xaml.cs file, add a property to the App
class, that gives other classes in your solution
access to the connection string.

Our connection string points to the Northwind


database in a SQL Server Express instance.
sealed partial class App : Application

{
// Connection string for using Windows Authentication.
private string connectionString =
@"Data Source=YourServerName\SQLEXPRESS;Initial
Catalog=NORTHWIND;Integrated Security=SSPI";

// This is an example connection string for using SQL Server Authentication.


// private string connectionString =
// @"Data Source=YourServerName\YourInstanceName;Initial
Catalog=DatabaseName; User Id=XXXXX; Password=XXXXX";

public string ConnectionString { get => connectionString; set =>


connectionString = value; }

...
}
Create a class to hold product data
We'll create a class that implements the INotifyPropertyChanged event so that we can bind attributes in
our XAML UI to the properties in this class.

public class Product : INotifyPropertyChanged


{
public int ProductID { get; set; }
public string ProductCode { get { return ProductID.ToString(); } }
public string ProductName { get; set; }
public string QuantityPerUnit { get; set; }
public decimal UnitPrice { get; set; }
public string UnitPriceString { get { return UnitPrice.ToString("######.00"); } }
public int UnitsInStock { get; set; }
public string UnitsInStockString { get { return UnitsInStock.ToString("#####0"); } }
public int CategoryId { get; set; }

public event PropertyChangedEventHandler PropertyChanged;


private void NotifyPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

}
References:-
https://learn.microsoft.com/en-us/visualstudio/get-started/csharp/tutori
al-uwp?view=vs-2022

https://www.tutorialspoint.com/windows10_development/windows10_
development_uwp.htm
Week – 11 – Summary:-

4. Develop integrated data-driven applications


such using SQL Server and UWP.

4.1. Develop a client system to use a database and


SQL commands.

4.2. Design and use a Business Data Layer to


communicate between client and server.

You might also like