0

Here is the Code:

    public long AddCase(Customer addCust)
    {
        using (var db1 = new SQLiteConnection(_helper.WritableDatabase.Path)) //Null Exception:Error
        {
            try
            {
                return db1.Insert(addCust);
            }
            catch (Exception ex)
            {
                //catch Exception;
            }
        }
    }

I am trying to invoke the above function with the code below

DatabaseUpdates ManageDb = new DatabaseUpdates();
ManageDb.SetContext(this);

DatabaseUpdates upd = new DatabaseUpdates();

upd.UpdateCustomer(var);
Name.Text = "";

. . I have a function to check if _helper is null or not..,

if (context != null)
            {
                _helper = new DataManagerHelper(context);
            }

Well I want to know what actually SQLiteConnection(dbpath) means. Why its showing null Exception. I know the concept why it declares null exception. Please help me understand why the below code gives me an error,

**using (var db1 = new SQLiteConnection(_helper.WritableDatabase.Path)) //Null Exception:Error**

No build errors. There are debug errors. Please help

Harshith C
  • 103
  • 2
  • 7
  • Its not duplicate. If you really find it duplicate then please help me how it is a duplicate. Please help me understand that error – Harshith C Aug 15 '16 at 15:24
  • Either _helper is null or _helper.WritableDatabase is null, or Path is null and the error occurs in the sqliteconnection constructor – rlee Aug 15 '16 at 15:25
  • Hmmm.. Thank you @bro. Well I need a solution for that. I am even trying to understand that SQLiteOpenHelper function too – Harshith C Aug 15 '16 at 16:06

0 Answers0