Hello guys,

    I found this code at http://www.mono-project.com/SQL_Lite

I want to ask why it is important to assign null to the Sqlite objects used in the main function. Since the function will exit and the local variables used will be deallocated,
   Is it really important to assign *null *to those variables?
   Is there a specific behaviour of Mono Sqlite that I should know about?

Thanks in advance,
Marc Glenn

*Please see code below:
*     using System;
    using System.Data;
    using Mono.Data.SqliteClient;

    public class Test
    {
       public static void Main(string[] args)
       {
          string connectionString = "URI=file:SqliteTest.db";
          IDbConnection dbcon;
          dbcon = (IDbConnection) new SqliteConnection(connectionString);
          dbcon.Open();
          IDbCommand dbcmd = dbcon.CreateCommand();
          // requires a table to be created named employee
          // with columns firstname and lastname
          // such as,
          //        CREATE TABLE employee (
          //           firstname varchar(32),
          //           lastname varchar(32));
          string sql =
             "SELECT firstname, lastname " +
             "FROM employee";
          dbcmd.CommandText = sql;
          IDataReader reader = dbcmd.ExecuteReader();
          while(reader.Read()) {
               string FirstName = reader.GetString (0);
               string LastName = reader.GetString (1);
               Console.WriteLine("Name: " +
                   FirstName + " " + LastName);
          }
          *// 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