ADO.NETObjects
Upcoming SlideShare
Loading in...5
×
 

ADO.NETObjects

on

  • 1,217 views

 

Statistics

Views

Total Views
1,217
Views on SlideShare
1,217
Embed Views
0

Actions

Likes
0
Downloads
109
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

ADO.NETObjects ADO.NETObjects Presentation Transcript

  • ADO.NET Objects
    SqlCommand
    SqlConnection
    SqlDataReader
    SqlDataAdapter
    DataTable
    DataSet
    DataView
  • ADO.NET Objects
    • Connection helps you identify
    Database Server
    Database Name
    Password
    UserName
    SqlConnection
    Database
  • ADO.NET Objects
    SqlConnection con= new SqlConnection (“Data Source=(local);Initial
    Catalog=Master; Integrated Security=SSPI”);
    SqlConnection con= new SqlConnection (“Server=<Servername>;Data
    Source=(local);uid=<SqlServerUserId>;Pwd=<SqlServer Password>”);
  • ADO.NET Objects
    • Various methods available in SqlConnection Object
    • Open()
    • Opens the connection to our database
    • Close()
    • Closes the database connection
    • Dispose()
    • Releases the resources on the connection object
  • ADO.NET Objects
    • SqlCommand
    • Used to execute commands to a database across a data
    connection
    • Send SQL statements to the database to perform certain action
    • What type of interaction you want to perform with a database
    Select
    Insert
    Delete
    Update
    SqlConnectioncon=new SqlConnection(“Data Source=(local);Initial
    Catalog=Master; Integrated Security=SSPI”);
    Con.Open();
    SqlCommandcmd=newSqlCommand(“select * from student”,con);
    Con.Close();
  • ADO.NET Objects
    • Various Methods Available in SqlCommand Object
    • ExecuteNonQuery()
    • Expects to run a command or a stored procedure
    • ExecuteScalar()
    • Returns only one value after executing the query
    • ExecuteReader()
    • Expects to run a query command or a stored procedure
    that SELECTS records
  • ADO.NET Objects
    • SqlDataReader
    • Provides a forward-only, read-only, connected stream record set
    from a database
    • Returned as the result of the Commandobject's ExecuteReader()
    SqlCommandcmd=new SqlCommand(“select * from student” , con);
     
    SqlDataReaderre=cmd . ExecuteReader();
  • ADO.NET Objects
    • Basic Methods available in SqlDataReader Object
    • Read()
    • Used to move the Record Pointer to the first row which
    allows the data to be read by the column name or the index
    position
    • HasRow()
    • Checks if any data exists, and it is used instead of the Read()
    • Close()
    • Used to close the SqlDataReader()