Friday, December 25, 2009

ADO.Net 2.0 Notes(part three)

Query of Database with SqlCommand class and SqlDataReader Class

1. create command
a. SqlCommand cmd = new SqlCommand()
cmd.Connection = cn; // cn is the instance of SqlConnection
cmd.CommandText = "SQL ... " ;
b. SqlCommand cmd ;
cmd = cn.createCommand() ;
cmd.CommandText = "SQL ..." ;
c. SqlCommand cmd = new SqlCommand( SQL , cn ) ;

2. SqlDataReader reader = cmd.ExecuteReader() ; ( cmd is the instance of SqlCommand class)
reader.read() ;


No comments:

Post a Comment