Every time this error problem with dt.
strSql = string.Format("Insert InTo MoneyEntries (Amount, EntryDate, Description, IDCategory)" +
"Values ('{0}', '{1}', '{2}', '{3}')", am, dt, desc, int.Parse(rdr[0].ToString()));
In my table Entrydate have type easy date. Please help
Loading

VulpesRank #55 · 29.2K reputationPosted Jul 18, 2011, 4:31 AM EDT
strSql = "Insert InTo MoneyEntries (Amount, EntryDate, Description, IDCategory) Values ('" + am.ToString() + "','" + dt.ToString("MM/dd/yyyy") + "','" + desc.ToString() + "','" + rdr[0].ToString() +"')'";
Dorababu MekaRank #457 · 5.5K reputationPosted Jul 18, 2011, 1:53 AM EDT
Mike JonsonRank #7,584 · 238 reputationPosted Jul 18, 2011, 1:57 AM EDT
Mike JonsonRank #7,584 · 238 reputationPosted Jul 18, 2011, 2:00 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 18, 2011, 2:04 AM EDT
We had another thread on this problem recently (http://www.c-sharpcorner.com/Forums/Thread/131973/inserting-date-value.aspx).
Also I'm surprised it works at all without a space before 'Values'.
I'd also remove the single quotes for the int value.
Dorababu MekaRank #457 · 5.5K reputationPosted Jul 18, 2011, 2:13 AM EDT
dt.ToUniversalTime().ToString(CultureInfo.CurrentCulture)
Mike JonsonRank #7,584 · 238 reputationPosted Jul 18, 2011, 3:00 AM EDT
Mike JonsonRank #7,584 · 238 reputationPosted Jul 18, 2011, 3:41 AM EDT
Mike JonsonRank #7,584 · 238 reputationPosted Jul 18, 2011, 4:43 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 18, 2011, 5:01 AM EDT
Mike JonsonRank #7,584 · 238 reputationPosted Jul 18, 2011, 5:54 AM EDT