Hello again...<BR> I have a simple insert string, which pulls data from a form and enters it into a database. I want to insert the date as well, but I haven't been able to get it to work. Here's the sql statement:<BR><BR> myCommand = New OleDbCommand( "Insert INTO info ( Name, DateToday ) Values ( 'Lor', '" & Date() & "' )", myConnection )<BR> myCommand.ExecuteNonQuery()<BR><BR>It just says "BC30108: 'Date' is a type, and so is not a valid expression." If anyone could help that would be great. Thanks!Hi LorKel,<BR><BR>There are at least two ways to go about this. The first, and easiest, would be to use SQL to get your date like so:<BR><BR>myCommand = New OleDbCommand( "Insert INTO info ( Name, DateToday ) Values ( 'Lor', GETDATE())", myConnection )<BR>myCommand.ExecuteNonQuery()<BR><BR>The second would be to use System.DateTime like so:<BR><BR>dim curDate AS date = new System.DateTime().Now.ToString() <BR><BR>myCommand = New OleDbCommand( "Insert INTO info ( Name, DateToday ) Values ( 'Lor', '" & curDate & "' )", myConnection )<BR>myCommand.ExecuteNonQuery()<BR><BR>Either way will work, the first example will return the full datetime. You could use DATEPART to grab just the date, but that's a different post. <BR><BR>])ry<BR>Thanks so much!
Try using DateTime.Today instead of the old VB6 Date().<BR><BR>Greg
