Querying with the DataReader
The CData ADO.NET Provider for Amazon S3 implements two ADO.NET interfaces you can use to retrieve data from Amazon S3: AmazonS3DataAdapter and AmazonS3DataReader objects. Whereas AmazonS3DataAdapter objects retrieve a single result set of all the data that matches a query, AmazonS3DataReader objects fetch data in subset increments as needed.
Using the AmazonS3DataReader
The AmazonS3DataReader retrieves data faster than the AmazonS3DataAdapter because it can retrieve data in pages. As you read data from the AmazonS3DataReader, it periodically requests the next page of results from the data source, if required. This causes results to be returned at a faster rate. The following example selects all the columns from the Buckets table:
C#
string connectionString = "AWSAccessKey=a123;AWSSecretKey=s123;"; using (AmazonS3Connection connection = new AmazonS3Connection(connectionString)) { AmazonS3Command cmd = new AmazonS3Command("SELECT * FROM Buckets", connection); AmazonS3DataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["Name"], rdr["OwnerId"])); } }
VB.NET
Dim connectionString As String = "AWSAccessKey=a123;AWSSecretKey=s123;" Using connection As New AmazonS3Connection(connectionString) Dim cmd As New AmazonS3Command("SELECT * FROM Buckets", connection) Dim rdr As AmazonS3DataReader = cmd.ExecuteReader() While rdr.Read() Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("Name"), rdr("OwnerId"))) End While End Using