Lecture 7. 1. Select Operation 2. Insert Operation 3. Update Operation 4. Delete Operation.

Slides:



Advertisements
Similar presentations
ADO.Net Modelo para acesso a dados nas aplicação.Net Componentes: DataSet.Net Data providers: Connection Command DataReader DataAdapter.
Advertisements

Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Introduction to Database Processing with ADO.NET.
1 ADO.NET. 2.NET Framework Data Namespaces System.Data –Base set of classes and interfaces for ADO.NET System.Data.Common –Classes shared by the.NET Data.
ADO. NET. What is “ADO.Net”? ADO.Net is a new object model for dealing with databases in.Net. Although some of the concepts are similar to the classical.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
In C# program Before you can start using the ODBC class definitions, you will need to include the right module. using System.Data.Odbc; // ODBC definitions.
C# programming with database Basic guideline. First step Install SQL Server 2008/2010 (Professional edition if possible) Install Visual Studio 2008/2010.
ADO.NET – part II August 2004 [ Marmagna Desai]. CONTENTS ADO vs ADO.NET ADO.NET – Managed providers Connecting to Database SqlConnection Selecting Database.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Microsoft Upgrade: Transition your MCPD.NET Framework 3.5 Web Developer Skills to MCPD.NET Framework 4 Web Developer Thousands of IT Professionals.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Intro to C#.net and EF Ilan Shimshoni. The Three Faces of ADO.NET The connected layer – Directly connecting to the DB The disconnected layer – Using datasets.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 4. 2 Overview Data Binding Data Providers Data Connection Data Manipulations.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
PART 1 CREATING THE PRODUCT CATALOG. ROADMAP FOR THIS CHAPTER To implement the departments list, you’ll start with the database and make your way to the.
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Neal Stublen Populating a Database  SQLExpress should be installed with Visual Studio  The book provides a.sql file for populating.
UNIT 9.2: Learning Objectives Agile Development – Bruce Feiler on Agile Programming Database access from code – Database Cycle Review – SQL Command Types.
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.Net.
.NET Data Access and Manipulation ADO.NET. Overview What is ADO.NET? Disconnected vs. connected data access models ADO.NET Architecture ADO.NET Core Objects.
MySQL Connection using ADO.Net Connecting to MySQL from.NET Languages.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with Disconnected Data The DataSet and SqlDataAdapter ADO.NET - Lesson.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL ADO.Net Basics Ruwan Wijesinghe Trainer.
Module 9: Accessing Relational Data Using Microsoft Visual Studio.NET.
Session 8: ADO.NET. Overview Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET.
Module 7: Accessing Data by Using ADO.NET
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Introduction to ADO.NET ADO.NET - Lesson 01  Training time: 10 minutes  Author:
An Introduction to ADO.Net Marmagna Desai.NET Seminar, Fall-2003.
ADO.NET Objects – Data Providers Dr. Ron Eaglin. Requirements Visual Studio 2005 Microsoft SQL Server 2000 or 2005 –Adventure Works Database Installed.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
Command Object’s ExecuteNonQuery Method ISYS 512.
C# Programming in Depth Prof. Dr. Bertrand Meyer March 2007 – May 2007 Chair of Software Engineering Lecture 10: Database Lisa (Ling) Liu.
1 11/10/05CS360 Windows Programming ADO.NET. 2 11/10/05CS360 Windows Programming ADO.NET  Behind every great application is a database manager o Amazon.
Mauricio Featherman, Ph.D. Washington St. University
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.Net.
HNDIT Rapid Application Development
Module 4 Introduction ADO.NET.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 The SqlCommand Object ADO.NET - Lesson 03  Training time: 15 minutes  Author:
ADO .NET from. ADO .NET from “ADO .Net” Evolution/History of ADO.NET MICROSOFT .NET “ADO .Net” Evolution/History of ADO.NET History: Most applications.
.NET Data Access and Manipulation
 ADO.NET is an object-oriented set of libraries that allows you to interact with data sources  Commonly, the data source is a database, but it could.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET Fundamentals.
Introduction to Database Processing with ADO.NET
ADO.NET and Stored Procedures
ADO.NET Framework.
Programming the Web Using ASP.Net
How to Create Login Form using vb.net and SqlServer Database
Lecture 6 VB.Net SQL Server.
How to use ADO.NET to write your own data access code
Unit 9.2 Database access from code Database Cycle Review
SQL commands from C# and ASP.net
VB.NET Using Database.
ADO.Net and Stored Procedures
מתחברים למסד נתונים היכרות עם ADO.Net.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
MySQL Connection using ADO.Net
Browser (Client Side) 瀏覽器 (客戶端)
Chapter 10 ADO.
E-commerce Applications Development
PROG Advanced Web Apps 4/13/2019 Programming Data Pages Wendi Jollymore, ACES.
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to Database Programming through ADO. NET
ADO.NET Fundamentals.
Presentation transcript:

Lecture 7

1. Select Operation 2. Insert Operation 3. Update Operation 4. Delete Operation

Dim connetionString As String Dim cnn As SqlConnection Dim cmd As SqlCommand Dim sql As String // var for command Dim reader As SqlDataReader connetionString = "Data Source=.\SqlExpress;Initial Catalog=my_database;Integrated Security=True“ sql = "select * from table_1“ cnn = New SqlConnection(connetionString) Try cnn.Open() cmd = New SqlCommand(sql, cnn) reader = cmd.ExecuteReader() While reader.Read() MsgBox(reader.Item(0) & " - " & reader.Item(1) & " - " & reader.Item(2)) End While reader.Close() cmd.Dispose() cnn.Close() Catch ex As Exception MsgBox("Can not open connection ! ") End Try

 The ExecuteReader method call is suitable when the underlying command object is set with the Select statement.  Select statement will return one or more records and those records are packed in SqlDataReader by the ExecuteReader method and then returned to the caller.  cmd.Dispose()  Dispose releases all the resources used by the object.

 SQL Adapter:  Initializes a new instance of the SqlDataAdapter class with a SelectCommand and a SqlConnection object.  Provides the communication between the Dataset and the Datasource.  That is the DataAdapter uses the Select statements to fill a DataSet ▪ and  use the other three SQL commands (Insert, Update, delete) to transmit changes back to the Database.

 Dim connetionString As String  Dim connection As SqlConnection  Dim adapter As New SqlDataAdapter  Dim sql As String  connetionString = "Data Source=.\SqlExpress;Initial Catalog=my_database;Integrated Security=True“  connection = New SqlConnection(connetionString)  sql = "insert into table_1 (id,name,batch) values(3,'Babar','2k13')“  Try  connection.Open()  adapter.InsertCommand = New SqlCommand(sql, connection)  adapter.InsertCommand.ExecuteNonQuery()  MsgBox("Row inserted !! ")  Catch ex As Exception ▪ MsgBox(ex.ToString)  End Try

 Dim connetionString As String  Dim connection As SqlConnection  Dim adapter As New SqlDataAdapter  Dim sql As String  connetionString = "Data Source=.\SqlExpress;Initial Catalog=my_database;Integrated Security=True"  connection = New SqlConnection(connetionString)  sql = "update table_1 set name = 'zeeshan' where id = 3“  Try  connection.Open()  adapter.UpdateCommand = connection.CreateCommand  adapter.UpdateCommand.CommandText = sql  adapter.UpdateCommand.ExecuteNonQuery()  MsgBox("Row updated !! ")  Catch ex As Exception  MsgBox(ex.ToString)  End Try

 Dim connetionString As String  Dim connection As SqlConnection  Dim adapter As New SqlDataAdapter  Dim sql As String  connetionString = "Data Source=.\SqlExpress;Initial Catalog=my_database;Integrated Security=True“  connection = New SqlConnection(connetionString)  sql = "delete table_1 where id =4“  Try  connection.Open()  adapter.DeleteCommand = connection.CreateCommand  adapter.DeleteCommand.CommandText = sql  adapter.DeleteCommand.ExecuteNonQuery()  MsgBox("Row(s) deleted !! ")  Catch ex As Exception  MsgBox(ex.ToString)  End Try

Assignment: Write a calculator program in VB.Net. Assignment: Create web browser program with back button. Assignment: Write short description of VB.net controls covered in class (Handwritten). Assignment: What are advantages of VB.net in comparison with Visual Basic 6? Assignment: Create a database of your class and retrieve it on Gridview.