Distributed Database Systems

Slides:



Advertisements
Similar presentations
17. Data Access ADO.Net Architecture New Features of ADO.NET
Advertisements

Coding ADO.Net DataSet Objects ISYS 512. DataSet Object A DataSet object can hold several tables and relationships between tables. A DataSet is a set.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
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.
Coding ADO.Net DataSet Objects. DataSet Object A DataSet object can hold several tables and relationships between tables. A DataSet is a set of disconnedted.
Coding ADO.Net DataSet Objects. DataSet Object A DataSet object can hold several tables and relationships between tables. A DataSet is a set of disconnedted.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Accessing Informix With ADO.Net Sean R. Durity Manager of IT CornerCap Investment Counsel Informix User Forum 2005 Moving Forward With Informix Atlanta,
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.
1/36 Database Programming with Visual Basic.Net and MS Access IKE Lab. Yunho Song Database Management and Analysis.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
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.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with Disconnected Data The DataSet and SqlDataAdapter ADO.NET - Lesson.
11 Using ADO.NET II Textbook Chapter Getting Started Last class we started a simple example of using ADO.NET operations to access the Addresses.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL ADO.Net Basics Ruwan Wijesinghe Trainer.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
ASP.NET Rina Zviel-Girshin Lecture 5
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.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
Using Adapter Wizard ISYS 512. Data Adapter Wizard – 2 nd Level of Using ADO.Net Configure Data Adapter and generating a dataset: –From the Data tab of.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Command Object’s ExecuteNonQuery Method ISYS 512.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Mauricio Featherman, Ph.D. Washington St. University
ADO.NET AND STORED PROCEDURES - Swetha Kulkarni. RDBMS ADO.NET Provider  SqlClient  OracleClient  OleDb  ODBC  SqlServerCE System.Data.SqlClient.
ASP.NET - insert - delete -update DataTables (disconnected datasets) Shopping Basket.
Distributed Database Systems INF413. ADO.NET is a set of classes that comes with the Microsoft.NET framework to facilitate data access from managed languages.
Building Informix Data- Driven Applications with.Net Sean R. Durity Manager of IT CornerCap Investment Counsel Informix User Forum 2006 Washington, D.C.
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.
1 11/15/05CS360 Windows Programming ADO.NET Continued.
HNDIT Rapid Application Development
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
Coding ADO.NET Objects: Connection, Command, DataReader.
Using ADO.Net to Build a Login System Dr. Ron Eaglin.
C# .NET Software Development
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.
DataGridView. Displaying data in a tabular format is a task you are likely to perform frequently. The DataGridView control is designed to be a complete.
Module 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.
Coding ADO.Net DataSet Objects ISYS 512. DataSet Object A DataSet object can hold several tables and relationships between tables. A DataSet is a set.
Introduction to Database C# MySQL onnect-C-to-MySQL 1.
.NET Data Access and Manipulation
C# MySQL onnect-C-to-MySQL 1.
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
Introduction to ADO.NET
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
ADO.NET and Stored Procedures
ADO.NET Framework.
© 2016, Mike Murach & Associates, Inc.
Programming the Web Using ASP.Net
How to Create Login Form using vb.net and SqlServer Database
Lecture 6 VB.Net SQL Server.
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
Chapter 10 ADO.
.NET Framework Data Providers
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

Distributed Database Systems INF413

ADO.Net Prepared statements When we write prepared statements, we use placeholders instead of directly writing the values into the statements. Prepared statements are faster and guard against SQL injection attacks. The @ID is a placeholder, which is going to be filled later.

ADO.Net SQL Injection User: asd Password: asd'; delete from aa where '1'='1

ADO.Net SQL Injection: Solution 1

ADO.Net SQL Injection: Solution 2 First create procedure Login in mysql: create procedure Login(id varchar(255),pass varchar(255)) BEGIN select * from users where uid=id and pwd=pass; END Then in C#: MySqlConnection con = new MySqlConnection("server=localhost;database=test;uid=root;pwd=root"); con.Open(); MySqlCommand cmd = new MySqlCommand("Login", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", textBox1.Text); cmd.Parameters.AddWithValue("@pass", textBox2.Text); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) MessageBox.Show("True"); else MessageBox.Show("False"); dr.Close(); con.Close();

ADO.Net Dataset DataSet is a major component of the ADO.NET architecture. The DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects. The data stored in the DataSet object is disconnected from the database! A DataSet is created in memory and used when extensive processing on data is needed or when we bind data tables to a Winforms control. When the processing is done, the changes are written to the data source. A MySqlDataAdapter is an intermediary between the DataSet and the data source. It populates a DataSet and resolves updates with the data source. A DataTable class holds the Rows collection, which contains a set of data rows or DataRow objects, and the Columns collection, which contains a set of data columns or DataColumn objects.

ADO.Net Creating and Using DataAdapter Objects string strConn = @”"; MySqlConnection cn = new MySqlConnection(strConn); string strSQL = “"; MySqlCommand cmd = new MySqlCommand(strSQL, cn); MySqlDataAdapter da = new MySqlDataAdapter(); da.SelectCommand = cmd;   OR:Using connection and SQL statment MySqlDataAdapter da = new MySqlDataAdapter(strSQL, strConn); OR:Using Command MySqlDataAdapter da = new MySqlDataAdapter(cmd);

ADO.Net

ADO.Net

ADO.Net MySqlDataAdapter da; DataSet ds = new DataSet(); private void button1_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; ds.Tables.Clear(); dataGridView1.Rows.Clear(); dataGridView1.Refresh(); da = new MySqlDataAdapter("select * from Users", "server=localhost;database=test;uid=root;pwd=root"); MySqlCommandBuilder cb = new MySqlCommandBuilder(da); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; } private void button2_Click(object sender, EventArgs e) da.Update(ds);

ADO.Net Data binding Keep the following two concepts in mind when you think about data binding: The direction that data flows between data sources and the data-bound controls and When the data flows. In one-way data binding, data flows only in one direction: values from properties of the data source are placed into properties on the user interface control, but there is no flow of data back from the control to the data source if those property values change within the control, at least not automatically. In two-way data binding, changes to the bound properties of a control also result in those changed values updating the corresponding data source values in the object in memory on the client. Most data-binding mechanisms in Windows Forms are designed to be two-way.

ADO.Net MySqlDataAdapter da; DataSet ds = new DataSet(); int i = 0; private void Form1_Load(object sender, EventArgs e) { da = new MySqlDataAdapter("select * from Users", "server=localhost;database=test;uid=root;pwd=root"); MySqlCommandBuilder cb = new MySqlCommandBuilder(da); da.Fill(ds); textBox1.DataBindings.Add("text", ds.Tables[0], "uid"); textBox2.DataBindings.Add("text", ds.Tables[0], "pwd"); }

ADO.Net private void First_Click(object sender, EventArgs e) { i = 0; textBox1.Text = ds.Tables[0].Rows[i][0].ToString(); textBox2.Text = ds.Tables[0].Rows[i][1].ToString(); } private void Next_Click(object sender, EventArgs e) i++; if (i < ds.Tables[0].Rows.Count) else i--; MessageBox.Show("Error");

ADO.Net private void Prev_Click(object sender, EventArgs e) { i--; if (i >= 0) textBox1.Text = ds.Tables[0].Rows[i][0].ToString(); textBox2.Text = ds.Tables[0].Rows[i][1].ToString(); } else i++; MessageBox.Show("Error"); private void Last_Click(object sender, EventArgs e) i = ds.Tables[0].Rows.Count-1;

ADO.Net Binding source A binding source acts as a proxy between bound controls and their associated data source. It provides one-stop shopping for accessing or managing the data-binding context for one or more controls on a form. You bind controls on a form to a binding source, and then you bind the binding source to a data source.

ADO.Net

ADO.Net

ADO.Net Image Data Binding uid varchar 255 pwd varchar 255 UserType varchar 255 UserImg longblob

ADO.Net

ADO.Net

ADO.Net

ADO.Net

ADO.Net

ADO.Net