DataView myData = ( DataView ) Cache [ "myDataSet" ];
if ( myData == null )
SqlConnection myConn = new SqlConnection (
"server=localhost;uid=sa;pwd=;database=pubs" );
SqlDataAdapter myCommand = new SqlDataAdapter ( "select * from Authors", myConn );
DataSet ds = new DataSet ( );
myCommand.Fill ( ds, "Authors" );
myData = new DataView ( ds.Tables [ "Authors" ] );
Cache [ "myDataSet" ] = myData;
}
myGrid.DataSource=myData;
myGrid.DataBind ( );
Dim myData As DataView = CType ( Cache ( "myDataSet" ), DataView )
If myData Is Nothing Then
Dim myConn As New SqlConnection ( _
"server=localhost;uid=sa;pwd=;database=pubs" )
Dim myCommand As New SqlDataAdapter ( "select * from Authors", myConn )
Dim ds As New DataSet ( )
myCommand.Fill ( ds, "Authors" )
myData = New DataView ( ds.Tables ( "Authors" ) )
Cache ( "myDataSet" ) = myData
End If
myGrid.DataSource = myData
myGrid.DataBind ( ) |