Calling Stored Procedures
You can invoke a stored procedure using SimpleDBCommand in the same way as any other SQL stored procedure. To instantiate a SimpleDBCommand, provide the name of the stored procedure and a SimpleDBConnection instance as arguments to the constructor. Set the CommandType property to StoredProcedure and add the parameters as key-value pairs to the Parameters collection of the SimpleDBCommand instance.
C#
string connectionString = "Access Key=My Amazon Access Key;Secret Key=My Amazon Secret Key;Offline=false;";
using (SimpleDBConnection connection = new SimpleDBConnection(connectionString)) {
SimpleDBCommand cmd = new SimpleDBCommand("CreateTable", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SimpleDBParameter("@Table", "MyNewTable"));
// Add other parameters as needed ...
SimpleDBDataReader rdr = cmd.ExecuteReader();
while (rdr.Read()) {
for (int i = 0; i < rdr.FieldCount; i++) {
Console.WriteLine(rdr.GetName(i) + " --> " + rdr[i]);
}
Console.WriteLine();
}
}
VB.NET
Dim connectionString As String = "Access Key=My Amazon Access Key;Secret Key=My Amazon Secret Key;Offline=false;"
Using connection As New SimpleDBConnection(connectionString)
Dim cmd As New SimpleDBCommand("CreateTable", connection)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SimpleDBParameter("@Table", "MyNewTable"))
' Add other parameters as needed ...
Dim rdr As SimpleDBDataReader = cmd.ExecuteReader()
While rdr.Read()
For i As Integer = 0 To rdr.FieldCount - 1
Console.WriteLine(rdr.GetName(i) + " --> " + rdr(i))
Next
Console.WriteLine()
End While
End Using