MySQL Connection using ADO.Net Connecting to MySQL from.NET Languages.

Slides:



Advertisements
Similar presentations
CE203 - Application Programming Autumn 2013CE203 Part 51 Part 5.
Advertisements

Aqua Data Studio. Find the application We are using Aqua Data Studio v11.
What is MySQL? MySQL is a relational database management system (A relational database stores data in separate tables rather than putting all the data.
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 JDBC Java Database Connectivity. 2 c.pdf
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
How to use MySql With C# Ross Sherman 1. Using MySql MySql is free. You could download it from:
Overview of Database Access in.Net Josh Bowen CIS 764-FS2008.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
CSCI 6962: Server-side Design and Programming
Overview of JDBC and Pro*C 1 Overview of JDBC,Pro*C and Oracle connectivity on Omega CSE 5330 – Database Systems.
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
ASP.NET Programming with C# and SQL Server First Edition
Connecting a.NET application to a database Jim Warren, COMPSCI 280 S Enterprise Software Development.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
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.
Active Server Pages ASP is Microsoft’s server-side script engine for dynamically-generated web pages. Most common language used is VBScript. If you use.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
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.
MySQL, Java, and JDBC CSE 3330 Southern Methodist 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.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
.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.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
Overview of JDBC and Pro*C 1 CSE 5330 – Database Systems.
JDBC. JDBC stands for Java Data Base Connectivity. JDBC is different from ODBC in that – JDBC is written in Java (hence is platform independent, object.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL ADO.Net Basics Ruwan Wijesinghe Trainer.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
Module 7: Accessing Data by Using ADO.NET
Copyright  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
Java Database Connectivity. Java and the database Database is used to store data. It is also known as persistent storage as the data is stored and can.
DT228/3 Web Development Databases. Querying a database: Partial info Search engines, on-line catalogues often need to allow user to search a database.
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.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
Presentation On How To Create Connection To A Database.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
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.
1 11/8/05CS360 Windows Programming Databases and Data Representation.
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.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
JDBC Java and Databases. SWC – JDBC JDBC – Java DataBase Connectivity An API (i.e. a set of classes and methods), for working with databases in.
1 JDBC – Java Database Connectivity CS , Spring 2010.
In the Name Of Almighty Allah. Java Application Connection To Mysql Created by Hasibullah (Sahibzada) Kabul Computer Science Faculty Afghanistan.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
SQL pepper. Why SQL File I/O is a great deal of code Optimal file organization and indexing is critical and a great deal of code and theory implementation.
Introduction to Database C# MySQL onnect-C-to-MySQL 1.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_Oracle10g_JDBC 1 Application Development (JDBC)
.NET Data Access and Manipulation
1. Writing a Java program to connect to SQL Server 2008 and Create a table Populate the table (insert data) Perform queries to retrieve information from.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
C# MySQL onnect-C-to-MySQL 1.
ASP.NET Programming with C# and SQL Server First Edition
CS3220 Web and Internet Programming Database Access with JDBC
Chapter 15 Using a Database.
JDBC – Java Database Connectivity
Lecture 6 VB.Net SQL Server.
HW#4 Making Simple BBS Using JDBC
Aqua Data Studio.
MySQL Connection using ADO.Net
MSIS 655 Advanced Business Applications Programming
Social Media And Global Computing Creating DLLs with Visual Studio
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Presentation transcript:

MySQL Connection using ADO.Net Connecting to MySQL from.NET Languages

ADO.Net Architecture ADO.Net provides an architecture for communicating between an application and a data source. The “data source” can be anything that has the required API, but usually it is a database server. Data Source Connection Object (ADO.Net) Data Adaptor Dataset (Local) Application

MySQL ADO.Net Provider MySqlConnection is main connection to the MySQL database MySqlCommand enables the execution of any command against the database. MySqlDataReader provides fast, forward- only read access to the database. MySqlDataAdapter serves as an interface between the MySQL data classes and the Microsoft DataSet. MySqlParameter used to store dynamic parameters for a command. MySqlTransaction used to represent a MySQL transaction.

Getting MySqlConnector.Net You need a MySql "Connector" for.Net applications. Download from Run the installer. The connector registers itself with the "Global Assembly Cache" so that the DLL can be found. Difference from Java: Java uses a CLASSPATH to find code; Visual Studio uses Windows Registry to find resources. (Optional for visual programming) Add the components to the Toolbox in Visual Studio: Tools -> Add/Remove Toolbox Items... orTools -> Choose Toolbox Items...

Undefined MySql Namespace in C# After installing MySqlConnector.Net, in your project you would add its name space to your C# source code using MySql.Data.MySqlClient; but, you may get a compiler error that the "MySql" name space is not found. in this case, add a reference to the Connector's DLL file: 1. Project -> Add Reference -> Browse 2. Find the.Net2.0 MySqlData.dll file, ex: C:/MySql/MySqlConnector.Net/bin/.Net 2.0/MySqlData.dll This should fix the name space problem.

Creating a Connection Object Connection Object manages the connection to database server. You must specify: server name, username, password Can omit unnecessary attributes or leave blank. string connectString = "Data Source=localhost;Database=bank;User Id=bank;Password=FatChance"; MySqlConnection myconn = new MySqlConnection( connectString ); public DBConnection(string host, string database, string user, string pass) { string connectString = String.Format( "Data Source={0};Database={1};User Id={2};Password={3}", host, database, user, pass); MySqlConnection myconn = new MySqlConnection( connectString ); } Better programming:

Opening the Connection After creating connection, open it. This may throw a MySqlException MySqlConnection myconn = null; try { myconn = new MySqlConnection( connectString ); myconn.Open(); } catch ( MySqlException e ) { Console.WriteLine("Error connecting to server: "+e.Message); }

Creating a Command Object Use a MySqlCommand object to issue database cmds A Command object is like a Java Statement object. You can reuse a Command object. Requires a Connection object (myconn) as param. MySqlCommand cmd = new MySqlCommand("SHOW TABLES;", myconn); MySqlDataReader reader = cmd.ExecuteReader( ) Method of executing command depends on the SQL statement:  UPDATE, INSERT, DELETE: cmd.ExecuteNonQuery() returns int.  SHOW (QUERY): cmd.ExecuteReader() returns MySqlDataReader Semi-colon

Processing Query Data MySqlDataReader has many methods for getting data by column number, column name, or index. Iterate over results using (boolean) reader.Read( ) MySqlDataReader reader = null; try { reader = cmd.ExecuteReader( ); if ( reader == null ) { Console.WriteLine("ExecuteReader failed"); return; } while( reader.Read() ) { Console.WriteLine( reader.GetString(0) ); } } catch ( MySqlException e) { Console.WriteLine("caught exception " + e.Message ); } finally { if (reader != null) reader.Close(); }

Resources MySQL Learning SQL nice tutorial and command reference Learning JDBC JDBC Trail in Sun's Java Tutorial. Dietel, Java How To Program, Chapter and zillions of resources on the web