There's a .NET API for Amazon Web Services, but I'm not a great C# programmer. I prefer Visual Basic as a language and was able to use the C# code in my Visual Basic project as a class - and worked with that structure for several weeks. Eventually, though, to create more sophisticated programs, I decided to port the C# code for retrieving data from a SimpleDB domain to Visual Basic.
I'm posting this because I wasn't able to find anything like this online. At all.
Imports Amazon
Imports Amazon.SimpleDB
Imports Amazon.SimpleDB.Model
...
Dim appConfig As NameValueCollection = ConfigurationManager.AppSettings
Dim sdb As AmazonSimpleDB = Amazon.AWSClientFactory.CreateAmazonSimpleDBClient(appConfig("AWSAccessKey"), appConfig("AWSSecretKey"))
Dim selectStatement As String = "Select * from testdomain"
Dim selectRequestAction As New SelectRequest
selectRequestAction.WithSelectExpression(selectStatement)
Dim selectResponse As SelectResponse = sdb.Select(selectRequestAction)
If selectResponse.IsSetSelectResult Then
Dim selectResult As SelectResult
selectResult = selectResponse.SelectResult
For Each item As Item In selectResult.Item
For Each attribute As Attribute In item.Attribute
If attribute.Name = "title" Then
Response.Write(attribute.Value)
End If
...
Next
Next
End If
This is the core of the code. It's basically a Visual Basic translation of the retrieval portions of the SimpleDB C# code sample that's included in the AWS .NET SDK.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment