Chapter 16 slides - Chapter 16 How to use ADO.NET to write...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Murach’s Visual Basic 2008, C16 © 2008, Mike Murach & Associates, Inc. Slide 1 Chapter 16 How to use ADO.NET to write your own data access code
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Murach’s Visual Basic 2008, C16 © 2008, Mike Murach & Associates, Inc. Slide 2 Objectives Applied Use a data reader to retrieve data from a database. Use data commands to execute action queries or queries that return a scalar value. Use parameters to limit the data that’s processed by a data command. Knowledge Describe the use of parameters with SQL statements. Describe the use of a data reader. Describe the use of the two types of queries that don’t return result sets.
Background image of page 2
Murach’s Visual Basic 2008, C16 © 2008, Mike Murach & Associates, Inc. Slide 3 Two constructors for the SqlConnection class New SqlConnection() New SqlConnection( connectionString ) Common properties and methods of the SqlConnection class Property Description ConnectionString Provides information for accessing a SQL Server database. Method Description Open() Opens the connection using the specified connection string. Close() Closes the connection.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Murach’s Visual Basic 2008, C16 © 2008, Mike Murach & Associates, Inc. Slide 4 Common values used in the ConnectionString property for SQL Server Name Description Data source/Server Name of the instance of SQL Server you want to connect to. Initial catalog/Database Name of the database you want to access. Integrated security Determines whether the connection is secure. Valid values are True, False, and SSPI. User ID User ID used to log in to SQL Server. Password/Pwd Password used to log in to SQL Server. Persist security info Determines whether sensitive information is returned as part of the connection. Workstation ID Name of the workstation that’s connecting to SQL Server.
Background image of page 4
Murach’s Visual Basic 2008, C16 © 2008, Mike Murach & Associates, Inc. Slide 5 Code that creates, opens, and closes a SQL connection Dim connectionString As String _ = "Data Source=localhost\SqlExpress; _ & "Initial Catalog=MMABooks;" _ & "Integrated Security=True" Dim connection As New SqlConnection() connection.ConnectionString = connectionString connection.Open() ... connection.Close() Another way to create a SqlConnection object Dim connection As New SqlConnection(connectionString) A connection string for the Jet OLE DB provider Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Databases\MMABooks.mdb
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Murach’s Visual Basic 2008, C16 © 2008, Mike Murach & Associates, Inc. Slide 6 Three constructors for the SqlCommand class New SqlCommand() New SqlCommand( commandText ) New SqlCommand( commandText , connection )
Background image of page 6
Murach’s Visual Basic 2008, C16 © 2008, Mike Murach & Associates, Inc. Slide 7 Common properties of the SqlCommand class Property Description Connection The connection used to connect to the database. CommandText A SQL statement or the name of a stored procedure.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 55

Chapter 16 slides - Chapter 16 How to use ADO.NET to write...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online