Neal Stublen Open/Close Connections  ADO.NET uses “connection pooling” to optimize opening and closing connections to the database.

Slides:



Advertisements
Similar presentations
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
Advertisements

Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
Using Multiple Forms. Creating a New Form ProjectAdd Windows Form.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
C# Programming: From Problem Analysis to Program Design1 Working with Files C# Programming: From Problem Analysis to Program Design 3 rd Edition 13.
File and Streams There are many ways of organizing records in a file. There are many ways of organizing records in a file. The most common type of organization.
Understanding Input/Output (I/O) Classes Lesson 5.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
WORKING WITH NAMESPACES
Chapter 4 Code Editor Goals and Objectives Program more efficiently? How can you speed up your development process? Do you want to learn useful shortcuts.
Neal Stublen Overview of.NET Windows Applications Microsoft Windows OS / Intel Platform Windows Application File SystemNetworkDisplay.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
ADO.NET By Hanumantha Rao.N MCA By Hanumantha Rao.N MCA.
Visual C Sharp – File I/O - 1 Variables and arrays only temporary - lost when a program terminates Files used for long term storage (Data bases considered.
Chapter 12 Working with Files CIS 3260 Introduction to Programming using C# Hiro Takeda.
Neal Stublen Class Objectives  Develop an understanding of the.NET Framework  Gain proficiency using Visual Studio  Begin learning.
HTML, XHTML, and CSS Chapter 12 Creating and Using XML Documents.
ASP.NET 2.0 Chapter 5 Advanced Web Controls. ASP.NET 2.0, Third Edition2 Objectives.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
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.
Neal Stublen Populating a Database  SQLExpress should be installed with Visual Studio  The book provides a.sql file for populating.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Session 1 SESSION 1 Working with Dreamweaver 8.0.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Thirteen Working with Access Databases and LINQ.
Neal Stublen Tonight’s Agenda  Interfaces  Generics  Code Organization  Databases  ADO.NET  Datasets  Q&A.
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Module 7: Accessing Data by Using ADO.NET
Neal Stublen Tonight’s Agenda  Database Errors  Parameterized queries  ToolStrip control  Master-detail relationships  Custom.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
Object Oriented Software Development 10. Persistent Storage.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Files and Streams. Objectives Learn about the classes that support file input/output Understand the concept of abstraction and how it related to the file.
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
CS360 Windows Programming
BIM313 – Advanced Programming File Operations 1. Contents Structure of a File Reading/Writing Texts from/to Files File and Directory Operations 2.
Understanding Databases Lesson 6. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Relational Database Concepts Understand relational.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Ten Structures and Sequential Access Files.
Input and Output 23: Input and Output
Ajay Tripathi Input Output. Ajay Tripathi Input/output (IO) refers to the operations for reading and writing data to streams and files. In the.NET Framework,
Understand Databound Controls Windows Development Fundamentals LESSON 4.2A.
Files and Streams. What is a file? Up until now, any stored data within a program is lost when the program closes. A file is a permanent way to store.
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
Files and Streams. Objectives Learn about the classes that support file input/output Understand the concept of abstraction and how it related to the file.
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Chapter 6: Creating Windows–based Applications 1 Microsoft® Visual C# 2008.
ASP.NET Programming with C# and SQL Server First Edition
INF230 Basics in C# Programming
Module 6: Building .NET–based Applications with C#
Input and Output 23: Input and Output
C# Programming: From Problem Analysis to Program Design
Using Multiple Forms.
How to work with files and data streams
CSCI 3327 Visual Basic Chapter 11: Files and Streams
Files and Streams.
Chapter 3 The .NET Framework Class Library (FCL)
Files and Streams Lect3 CT1411.
Sequential Input and Output using Text Files
File Input/Output (I/O)
Creating a Windows Forms User Interface
CIS16 Application Programming with Visual Basic
Files and Streams Lect10 GC201 12/1/2015.
Chapter 10 ADO.
Database Applications
How to work with files and data streams
Files and Streams.
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Presentation transcript:

Neal Stublen

Open/Close Connections  ADO.NET uses “connection pooling” to optimize opening and closing connections to the database  cxn.Open() and cxn.Close() are using connections from the connection pool that share the same connection string  ADO.NET manages the actual connection to the database  us/library/8xx3tyca(v=vs.110).aspx us/library/8xx3tyca(v=vs.110).aspx

Think of it like this… class SqlConnectionPool { public SqlConnection Open(string cxnStr) { if (mPool.Contains(cxnString)) { return mPool[cxnString]; } // Create a new connection... }

And… class SqlConnectionPool { public void CheckIdle() { foreach (cxn in mPool) { if (cxn.IsIdle()) { cxn.ReallyClose(); mPool.Remove(cxn); }

DataSets in Class Libraries  Create a DataSet in the class libraries  Select “Referenced DataSets” when adding a DataSet control to a form  Add a BindingSource  Add form controls and bind them to the BindingSource

Designer Walkthrough

Summary  MenuStrip w/ defaults  ToolStrip w/ defaults  StatusStrip  View Menu Toggles  PerformClick()  ToolStripContainer w/ docking  ContextMenuStrip  SplitContainer  ErrorProvider

File System Static Classes  System.IO namespace  Directory CreateDirectory, Exists, Delete  File Exists, Delete, Copy, Move  Path Combine, GetDirectoryName, GetFileName, GetExtension, GetTempFileName DirectorySeparatorChar, VolumeSeparatorChar

File System Instance Classes  DirectoryInfo EnumeratorDirectories(), EnumerateFiles()  FileInfo Name, Length, Open(), OpenText()

File System Exceptions  FileNotFoundException  DirectoryNotFoundException  EndOfStreamException  IOException

Stream Classes  FileStream  StreamReader  StreamWriter  BinaryReader  BinaryWriter

Code Practice  Browse for a text file  Place the filename in a TextBox  Read each line from the file and insert into a ListView  Use two columns in the ListView Line number Content

Review  OpenFileDialog  ImageList  ListView, DetailsView

What’s XML?  Structured data file  Tags identify each data element  Tags can have attributes and child tags   Having Fun in Kansas City  

XML Tags  Elements are identified by start tags,, and end tags,  Content can be placed between tags in the form of text or additional elements  Elements can be described using a single tag,  Comments are tags in the form,

Tag Attributes  In addition to content, each tag can also contain zero, one, or more attributes instead of child elements:

Working with XML Files  Any text editor can be used to create XML files  Visual Studio helps create and edit XML files Creates XML declaration Color coded tags Automatic indentation and closing tags Expanding and collapsing tags

XmlReader/XmlWriter  System.XML is the namespace that contains XML classes  Useful for exporting and importing data in a common format

Writing XML Files XmlWriter w = XmlWriter.Create(path, settings); w.WriteStartDocument(); // A start tag w.WriteStartElement(root_name); // A nested start tag w.WriteStartElement(parent_name); // An attribute on the parent_name tag w.WriteAttributeString(name, value); // A complete element w.WriteElementString(child_name, value); // End tags for parent_name and root w.WriteEndElement(); w.Close();

Using XMLWriterSettings  Define indentation XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " ";

Code Practice  Create a new project called CustomerExport  Export the rows from the Customers table to Customers.xml  Consider how you would use SqlConnection, SqlCommand, and SqlReader  Save the XML file on the Desktop as…

XML Format Abeyatunge, Derek 1414 S. Dairy Ashford North Chili NY

Review  MemoryStream  XmlWriter  SqlDataReader “inspection”  System.Environment.GetFolderPath  FileStream  Debugging visualizers