Forum: Building VoltDB Applications

Post: C# - using select

C# - using select
eitanm
Nov 5, 2015
Hello.
I downloaded the demo for C# as in your site.
Changed it a little to fit my own connection.


I want to select a range.
In Java example I had seen the class: org.voltdb.SQLStmt, but I didn't see something similar in C#.
How can I select a range from C#?

I shall be able to do select in C#, i.e for:
"select * from mytable where id in (123 .. 456)".

Thanks :)

Here is the code:


using System;
using VoltDB.Data.Client;

namespace VoltDB.Examples.HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // Read hosts from the command or use defaults
                string hosts = <myip>;
                if (args.Length > 0)
                    hosts = string.Join(",", string.Join(",", args).Split(' ', ','));

                // Create a connection and open it immediately.
                // Notice the "using" block that will ensure the connection is closed and disposed of at the end.
                using (var connection = VoltConnection.Create("hosts=" + hosts).Open())
                {

                    var Select = connection.Procedures.Wrap<SingleRowTable, string>("mytable.select");


                    if (Select.Execute("5026101980..5026101981").Result.HasData)
                    {
                        SingleRowTable result = (SingleRowTable)Select.Execute("5026101980..5026101981").Result;
                    }
                }
            }
            catch (Exception x)
            {
                Console.WriteLine(x.ToString());
            }

        }
    }
}