c# Console app examples

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
garthl
Posts: 3
Joined: Fri 29 Jul 2011 12:38

c# Console app examples

Post by garthl » Fri 29 Jul 2011 12:51

I downloaded the Free version for a quick look - but all the examples/samples I saw were forms based examples - is there a C# Console Sample around anywhere that walks through the basics ?

Cheers and thanks

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 29 Jul 2011 13:28


garthl
Posts: 3
Joined: Fri 29 Jul 2011 12:38

Thanks ..

Post by garthl » Mon 01 Aug 2011 05:15

ok, that was a bit more basic than what I was expecting , but I managed to see what I needed, thanks

Im -><- this close to ordering a full copy btw, even though at the moment Im not using it to its full potential (I dont need all the design type and ER things)

One thing I seem to be missing, is an easy way of doing an 'executeScalar' SQL function, that is,

SELECT COUNT(*) From Table;

I see you have 'user defined' scalar functions, and 'ExecuteNonQuery' ..obviously Ive been able to execute a standard SQL query and look at the first (and hopefully only) row/column returned - coming from c++ and CPPSQLite3 there was an executeScalar function which was modelled on ADO.NET

I know, Im a PITA - any pointer you can throw at me would be appreciated

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 02 Aug 2011 12:21

garthl wrote:One thing I seem to be missing, is an easy way of doing an 'executeScalar' SQL function, that is,

SELECT COUNT(*) From Table;
Try this code:

Code: Select all

    using (SQLiteConnection conn = new SQLiteConnection()) {
        conn.ConnectionString = @"Data Source = d:\sqlitetest.db"; //change to your path
        conn.Open();
        SQLiteCommand cmd = conn.CreateCommand();
        cmd.CommandText = "SELECT COUNT(*) From Table";
        int i = Convert.ToInt32(cmd.ExecuteScalar());
    }
garthl wrote:I see you have 'user defined' scalar functions
Please refer to our blog article: http://www.devart.com/blogs/dotconnect/ ... tions.html.

garthl
Posts: 3
Joined: Fri 29 Jul 2011 12:38

apologies

Post by garthl » Tue 02 Aug 2011 22:22

dont know how I missed that (ExecuteScalar()) d'oh - thanks ..for some reason I didnt see it

RTFM, then RTFM again I guess ..

expect a sale in the next 24 hours - thanks for your perserverence

Post Reply