void ExecuteReaderDemo ( string query, string connString ) {
OleDbConnection myConn = new OleDbConnection ( connString );
OleDbCommand myCommand = new OleDbCommand ( query, myConn );
myCommand.Connection.Open ( );
OleDbDataReader myReader = myCommand.ExecuteReader (
CommandBehavior.CloseConnection );
while ( myReader.Read ( ) ) {
Response.Write ( myReader.GetString ( 0 ) );
}
myReader.Close ( );
myConn.Close ( );
}
Public Sub ExecuteReaderDemo ( query As String, connString As String )
Dim myConn As New OleDbConnection ( connString )
Dim myCommand As New OleDbCommand ( query, myConn )
myCommand.Connection.Open ( )
Dim myReader As OleDbDataReader = myCommand.ExecuteReader ( _
CommandBehavior.CloseConnection )
While myReader.Read ( )
Response.Write ( myReader.GetString ( 0 ) )
End While
myReader.Close ( )
myConn.Close ( )
End Sub |