Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Lect 5 - Database Integration With Visual Studio

Database

Uploaded by

xxareefa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lect 5 - Database Integration With Visual Studio

Database

Uploaded by

xxareefa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Visual Programming

Visual Programming

Database Integration with Visual Studio

Database Server Related Aspects

By:
Zohair Ahmed

www.youtube.com/@zohairahmed007

www.youtube.com/@zohairahmed007 www.youtube.com/@zohairahmed007
Subscribe
www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007


www.begindiscovery.com

www.begindiscovery.com www.begindiscovery.com
What is Microsoft SQL Server?
• Microsoft SQL Server is a relational database management system (RDBMS) developed by
Microsoft.

• Used to store, manage, and retrieve data for a wide range of applications, from small desktop
apps to large enterprise systems.

• Reliability, scalability, and integration with Microsoft technologies are key features.

• Introduced in 1989, with regular updates and improvements.

www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com


Editions of SQL Server
• Enterprise Edition: Full features, designed for large businesses with high performance and
scalability requirements.

• Standard Edition: Essential database capabilities, suitable for mid-tier applications.

• Express Edition: Free, entry-level version with limited features, suitable for small
applications and development.

• Developer Edition: Full-featured version for non-production use, ideal for developers.

• Web Edition: Optimized for web hosting with cost-effective pricing.

www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com


SQL Server Management Studio (SSMS)
• SSMS is an integrated environment for
managing SQL Server infrastructure.

• Features include query writing and


execution, database management,
security management, and
backup/restore operations.

• Provides a user-friendly interface with


tools for development and database
administration.
www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com


Local DB
• Visual Studio provides several options for creating and working with databases in a .NET application. Here’s a list
of the commonly used database types that can be integrated directly within Visual Studio:
SQL Server Express (LocalDB)
• A lightweight, version of SQL Server Express specifically designed for developers.
• LocalDB is easy to install and use and is primarily used for local development and testing.
• Connection: LocalDB runs in user mode and doesn't require SQL Server to be installed.
• It is often accessed through the *.mdf (Master Database File) file directly and is managed through Visual Studio.
• Use Case: Best suited for development and testing scenarios when you don’t need a full SQL Server instance.
• Server Name: (localdb)\MSSQLLocalDB
‒ Backward Slash (\)
• Connection String :
‒ "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\YourDatabase.mdf;Integrated
Security=True;Connect Timeout=30;"
www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 5


Full-featured Edition of SQL server
SQL Server Express Edition

• A free, full-featured edition of SQL Server with some limitations (such as database size caps and
fewer advanced features). This version provides more capabilities than LocalDB, including support
for remote connections, making it suitable for lightweight production applications.

• Connection: Requires a full SQL Server Express installation, and you can connect to it as you
would any SQL Server instance.

• Use Case: Suitable for development and small to medium-scale production applications.

• Connection String :

‒ "Data Source=.\\SQLEXPRESS;Initial Catalog=YourDatabase;Integrated Security=True;"

www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 6


Authentication Methods
• Two primary authentication modes in SQL Server:

‒ Windows Authentication

‒ SQL Server Authentication

• Windows Authentication: Uses Windows user accounts to authenticate users.

• SQL Server Authentication: Uses SQL Server-specific usernames and passwords.

• Windows Authentication:

‒ Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=True;

• SQL Server Authentication:

‒ Data Source=ServerName;Initial Catalog=DatabaseName;User ID=YourUsername;


Password=YourPassword;
www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 7


Connection String
• A connection string is a string of parameters used to establish a connection between an application and a data
source, like a database.
• It contains key-value pairs specifying the details needed to access the database, such as the server location,
database name, user credentials, and other configuration settings.
• Data Source: Specifies the server or file containing the database.
‒ For SQL Server, this is often the server name or IP address.
‒ For file-based databases, it’s the file path.
• Initial Catalog / Database: Defines the specific database on the server that the application should connect to.
• User ID and Password: Credentials used to authenticate the connection. Alternatively, Integrated Security can be
used to rely on Windows authentication.
• Integrated Security: If set to True or SSPI, it uses Windows credentials for authentication instead of providing a
username and password.
• Additional Parameters: Optional configurations such as connection timeout, encryption, pooling, and more.

www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 8


Examples of Common Connection Strings
SQL Server Connection String (SQL Server Express or full SQL Server)
‒ "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=YourUsername; Password=YourPassword;"

• Data Source: The server’s name or IP address.


• Initial Catalog: The database to connect to.
• SQL Server LocalDB Connection String
‒ "Data
Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\YourDatabase.mdf;Inte
grated Security=True;"
• Data Source: (LocalDB)\MSSQLLocalDB specifies the local instance of SQL Server LocalDB.
• AttachDbFilename: Path to the .mdf file.
• Integrated Security=True: Uses Windows authentication.
www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 9


XML
• An XML (eXtensible Markup Language) file is a
<?xml version="1.0" encoding="UTF-8"?>
structured, text-based file format used to store and <company>
transport data. <employee id="101">
• It is both human-readable and machine-readable and is <name>John Doe</name>
commonly used for storing configuration information, data <position>Software Engineer</position>
exchange between systems, and many other purposes.
</employee>
<employee id="102">
Basic Structure of an XML File: <name>Jane Smith</name>
• An XML file consists of elements enclosed within tags (< >). <department>Management</department>
These tags are hierarchical, allowing for nesting to </employee>
represent complex data structures. </company>
• The app.config file in C# is a configuration file used to
define settings and parameters for a .NET application.

www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 10


Step to Make Start in Local DB

www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 11


LocalDB Verification and Installation
1. Verify LocalDB Installation
‒ Open a command prompt and type the following command to check if LocalDB is installed: sqllocaldb info
2. Start a LocalDB Instance Manually
‒ sqllocaldb start MSSQLLocalDB
3. Add LocalDB Using Visual Studio Installer:
‒ Open Visual Studio Installer (search for it in the Start menu).
‒ Click on Modify next to your installed version of Visual Studio.
‒ Navigate to Individual Components.
‒ Search for and select SQL Server Express 2019 LocalDB (or the version of LocalDB you need).
‒ Click on Modify to add this component to your current Visual Studio installation.
4. Install SQL Server Express LocalDB Manually:
1. Download SQL Server Express (which includes LocalDB)
2. Choose the installer for SQL Server Express and run it.
3. During the installation process, select Download Media and choose LocalDB as the option to install.

www.youtube.com/@zohairahmed007

www.begindiscovery.com

By : Zohair Ahmed www.youtube.com/@zohairahmed007 www.begindiscovery.com 12

You might also like