Danish Habib

Danish Habib

  • NA
  • 694
  • 244k

Reading datetime in sqlite

Oct 19 2015 3:16 AM
I have a desktop application in which i am saving the user with datetime 
while saving my table datatype is datetime
i am saving like that
com.Parameters.Add("@CreateDate", SqlDbType.DateTime).Value = _create.ToString("dd/MMM/yyyy");
 
while reading i am using that code
 
sql_cmd.CommandText = "SELECT UserName, IsNever, CreateDate, ValidDays, ExpireDate FROM Users WHERE (UserID = @UserID) AND (UserPassWord = @UserPassWord)";
sql_cmd.Parameters.Add("@UserID", SqlDbType.NVarChar).Value = UserID.ToString().Trim();
sql_cmd.Parameters.Add("@UserPassWord", SqlDbType.NVarChar).Value = PassWord.ToString().Trim();
rdr = sql_cmd.ExecuteReader();
while (rdr.Read())
{
objClsUsers = new ClsUserLoging();
objClsUsers.UserName = rdr.GetString(0).ToString();
objClsUsers.Never = rdr.GetBoolean(1);
objClsUsers.CreateDate = rdr.GetDateTime(2);
objClsUsers.ValidDays = (short)rdr.GetInt32(3);
objClsUsers.ExpireDate = rdr.GetDateTime(4);
}
rdr.Close();
 it gives exception on the highlited line that "Invalid DateTime Field Format: 19/Oct/2015" 
 
anyone can assists me in that regard Thanks in advance  
 
 

Answers (1)