Karan
Karan

Reputation: 252

How to retrive date from sqlite sql query and send to calling function

I am retrieving the date column value from db(sqlite).

public Contacts ReadDaysLeft(int daysid)            
{               
    using (var dbConn = new SQLiteConnection(App.DB_Path))               
    {                  
      var data = dbConn.Query<DaysLeft>("select  * from DaysLeft where Id = " + daysid).FirstOrDefault();

      DateTime dt =  Convert.ToDateTime(data.Date);      
      return data;                
    }      
}

I can get date value from that sql query by DateTime dt = Convert.ToDateTime(data.Date);

But my question is, how to send that date value to my calling function.. Please help

Upvotes: 1

Views: 111

Answers (1)

George Mamaladze
George Mamaladze

Reputation: 7931

Caller:

DateTime dt;
var result = ReadDaysLeft(123, out dt);
Console.WriteLine(dt); //Is that what you need?

Calee:

public Contacts ReadDaysLeft(int daysid, out DateTime dt)            
{               
    using (var dbConn = new SQLiteConnection(App.DB_Path))               
    {                  
      var data = dbConn.Query<DaysLeft>("select  * from DaysLeft where Id = " + daysid).FirstOrDefault();

      dt =  Convert.ToDateTime(data.Date);      
      return data;                
    }      
}

For more information see: out (C# Reference)

Upvotes: 1

Related Questions