Hello all

I attach a .cs that works on Linux but crashes always on the same
place on Windows, both with mono 1.2.4. Code

I compile the .cs on Linux and then i try on both platforms.

On Windows i put the sqlite3.dll on the running directory coming from here:
http://sqlite.org/download.html
concretely this:
http://sqlite.org/sqlitedll-3_4_0.zip

and i execute doing 'mono sqliteCrashWin.exe' from the mono command prompt.

remember to delete de SqliteTest.db before every new test.

there's also problems with the encoding on windows. I don't know if it's
related to the crash.

I tried also renaming other sqlitexxx.dll files with no success.

I use the SqliteConnection and not the IDbConnection because i don't
know how to  dbcon.LastInsertRowId with the IDbconnection

Any idea? Thanks

--------  code attached ---------

/*
sqliteCrashWin.cs
*/

//Compile with:
//gmcs sqliteCrashWin.cs -r:System.Data.dll -r:Mono.Data.Sqlite.dll


using System;
using System.Data;
//using Mono.Data.SqliteClient;         //1.0 profile
using Mono.Data.Sqlite;                 //2.0 profile

public class Test
{
        public static void Main(string[] args)
        {
                //1.1 profile
                //string connectionString = "URI=file:SqliteTest.db";
                //
                //2.0 profile
                string connectionString = "version = 3; Data 
source=SqliteTest.db";
//works but characters are not seen ok on windows command prompt


                Console.WriteLine("1 creating file SqliteTest.db  ... \n(if 
exists,
DELETE IT BEFORE RUNNING THIS PROGRAM)");
/*
                IDbConnection dbcon;
                dbcon = (IDbConnection) new SqliteConnection(connectionString);
                dbcon.Open();
                IDbCommand dbcmd = dbcon.CreateCommand();
*/
                SqliteConnection dbcon;
                dbcon = new SqliteConnection(connectionString);
                dbcon.Open();
                SqliteCommand dbcmd = dbcon.CreateCommand();

                Console.WriteLine("2 creating 1st table works...");

                string sql =
                        "CREATE TABLE employee (" +
                           "firstname varchar(32)," +
                           "lastname varchar(32))";
                dbcmd.CommandText = sql;
                dbcmd.ExecuteNonQuery();

                Console.WriteLine("3 creating 2nd table works...");

                sql =
                        "CREATE TABLE employeeText (" +
                           "firstname TEXT," +
                           "lastname TEXT)";
                dbcmd.CommandText = sql;
                dbcmd.ExecuteNonQuery();

                Console.WriteLine("4 creating 3d table works...");

                sql =
                        "CREATE TABLE jump ( " +
                        "uniqueID INTEGER PRIMARY KEY, " +
                        "personID INT, " +
                        "sessionID INT, " +
                        "type varchar(32), " +
                        "tv FLOAT, " +
                        "tc FLOAT, " +
                        "fall INT, " +
                        "weight varchar(32), " +
                        "description varchar(32) )";
                dbcmd.CommandText = sql;
                dbcmd.ExecuteNonQuery();

                Console.WriteLine("5 creating 4th table CRASHES ON WINDOWS...");
                sql =
                        "CREATE TABLE jumpText ( " +
                        "uniqueID INTEGER PRIMARY KEY, " +
                        "personID INT, " +
                        "sessionID INT, " +
                        "type TEXT, " +
                        "tv FLOAT, " +
                        "tc FLOAT, " +
                        "fall INT, " +
                        "weight TEXT, " +
                        "description TEXT )";
                dbcmd.CommandText = sql;
                dbcmd.ExecuteNonQuery();


                Console.WriteLine("6 inserting data table 1...");

                sql =
                        "INSERT INTO employee (firstname, lastname) " +
                        "VALUES ('my1stName', 'my2ndName')";
                dbcmd.CommandText = sql;
                dbcmd.ExecuteNonQuery();

                Console.WriteLine("7 selecting data table 1...");

                sql =
                        "SELECT firstname, lastname " +
                        "FROM employee";
                dbcmd.CommandText = sql;
                //IDataReader reader = dbcmd.ExecuteReader();
                SqliteDataReader reader = dbcmd.ExecuteReader();

                while(reader.Read()) {
                        string FirstName = reader.GetString (0);
                        string LastName = reader.GetString (1);
                        Console.WriteLine("Name: " +
                                        FirstName + " " + LastName);
                }
                
                Console.WriteLine("8 clean up...");

                // clean up
                reader.Close();
                reader = null;
                dbcmd.Dispose();
                dbcmd = null;
                dbcon.Close();
                dbcon = null;
        }
}
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to