This document discusses connecting a Visual Studio .NET application to a SQL Server database. It provides steps for installing Visual Studio and SQL Server, creating a database in SQL Server, adding tables and rows to the database, and adding database fields to a Windows forms application in Visual Studio. The steps include creating a data source, dataset, and connecting database fields to controls like a data grid view on a Windows form. This allows building an application that can execute queries and display data from the SQL Server database.
This document discusses connecting a Visual Studio .NET application to a SQL Server database. It provides steps for installing Visual Studio and SQL Server, creating a database in SQL Server, adding tables and rows to the database, and adding database fields to a Windows forms application in Visual Studio. The steps include creating a data source, dataset, and connecting database fields to controls like a data grid view on a Windows form. This allows building an application that can execute queries and display data from the SQL Server database.
This document discusses connecting a Visual Studio .NET application to a SQL Server database. It provides steps for installing Visual Studio and SQL Server, creating a database in SQL Server, adding tables and rows to the database, and adding database fields to a Windows forms application in Visual Studio. The steps include creating a data source, dataset, and connecting database fields to controls like a data grid view on a Windows form. This allows building an application that can execute queries and display data from the SQL Server database.
This document discusses connecting a Visual Studio .NET application to a SQL Server database. It provides steps for installing Visual Studio and SQL Server, creating a database in SQL Server, adding tables and rows to the database, and adding database fields to a Windows forms application in Visual Studio. The steps include creating a data source, dataset, and connecting database fields to controls like a data grid view on a Windows form. This allows building an application that can execute queries and display data from the SQL Server database.
Download as PPTX, PDF, TXT or read online from Scribd
Download as pptx, pdf, or txt
You are on page 1of 40
DATABASE CONNECTIVITY
Where does ADO sit?
VB C# C++ Jscript …
Visual Studio .NET
Common Language Specification
ASP.Net Windows Forms
ADO.Net XML.Net
Base Class Library
Common Language Runtime (CLR)
Windows COM+ Services
GETTING READY INSTALL VISUAL STUDIO
INSTALL SQL SERVER THAT IS
COMPACTIBLE FOR THE THAT
PARTICULAR VISUAL STUDIO VERSION.
CREATING A DATABASE Click Ok. Then the window will disappear and will be back to “Data Source configuration wizard” window.
Click next . Then you will be asked to save the
connection String. Click next.
Then Click finish. And your database is
created. ADDING TABLE TO DATABASE Open Server Explorer by following these steps. Go to Tool -> Connect to server. ADDING TABLE TO DATABASE A window will pop-up demanding for server name. just enter your pc name and click ok. ADDING TABLE TO DATABASE After clicking ok . A server explorer window appears on the left side as shown below. CREATING A DATABASE To create database in visual studio 2010, Select “Add New Data Source from data menu. ADDING TABLE TO DATABASE Now create table by right-clicking on table icon in server explorer window as follows: ADDING TABLE TO DATABASE Now the new window will open as : ADDING TABLE TO DATABASE Fill the data into the table as follows: ADDING TABLE TO DATABASE Now Press Ctrl + s to save the table ,then a pop-up window will appear for table name. Give a name to table as follows and click ok. ADDING TABLE TO DATABASE Now this add a table in the test database in server explorer having name Emp_Detail . ADDING ROWS TO TABLE Right click on Emp_Detail Table and click on “Show Table Data”. ADDING ROWS TO TABLE The new Window will appear as follows: ADDING ROWS TO TABLE Add data to the table as follows. ADDING ROWS TO TABLE Now after updating close the window.
Now close the Test.mdf connection by right-
clicking the “Test.mdf ” icon in server explorer. ADDING DATABASE FIELD TO FORMS CREATING A DATABASE The new window “Data source Configuration Wizard” will be opened. CREATING A DATABASE Select Database option from the above window. And then click next.
Now you will be asked to choose a dataset .
Choose dataset and click next.
This is shown in next slide. CREATING A DATABASE CREATING A DATABASE Now you are asked to choose the Data connection. CREATING A DATABASE Click on New Connection. This will open a Choose Data Source window. CREATING A DATABASE Choose your Data source suppose Microsoft Sql Server Database File then click to continue. CREATING A DATABASE Now the next window is Add Connection.
You may change your data source by clicking to change button.
Or Just Enter a new Database name or browse from any location.
Here we will create a new database named “Test” shown in next
slide. CREATING A DATABASE ADDING DATABASE FIELD TO FORMS Create a window application by going to File->New Project->Window Application.
Create a Dataset by Going to Data and then
clicking to Add New Dataset as follows. ADDING DATABASE FIELD TO FORMS ADDING DATABASE FIELD TO FORMS Now Click on Data tab and then click on “show data sources” ADDING DATABASE FIELD TO FORMS Now a Dataset explorer will appear on the left side of the visual studio window as follows : ADDING DATABASE FIELD TO FORMS Now Drag the columns of the table Test to the Form1 as follows: ADDING DATABASE FIELD TO FORMS Add a Data grid to the table as follows: ADDING DATABASE FIELD TO FORMS Drag and drop the table name from dataset explorer into the data grid view field as follows: ADDING DATABASE FIELD TO FORMS Now the Form Created Would look like this : ADDING DATABASE FIELD TO FORMS Now Your Form is connected to the database.
The Navigation bar on the top of the form
shows the following data. EXECUTION OF PROGRAM Thannks
Download Exploring CQRS and Event Sourcing A journey into high scalability availability and maintainability with Windows Azure 1st Edition Dominic Betts ebook All Chapters PDF