C# Insert Statement

I am using Microsoft Access database and I am trying to Insert a new record in a table. I have the insert statment. When you use varables that are string you have to put single quotes around it but what do u put around the System.Dateandtime.Now to insert it in the database. If you use the single quotes on it it throws a syntax error if you don't use anything it throws the same error. the field that I have in the table is a date/time field.  Can u help


Answer this question

C# Insert Statement

  • amberlianne

    You put octothorpes (pound sign) around a date, like this:
    "INSERT INTO TableName (MyDate) VALUES (#10/20/2005#)"

  • ddawsonb

    Hi,

    Instead of using System.Dateandtime.Now, you can use the NOW function of t-sql. ex:

    INSERT INTO myTable VALUES('1234', NOW())

     

     

    cheers,

    Paul June A. Domag



  • C# Insert Statement