How use NOW() function in InsertCommand

C

Cirene

In my HTML view of my ASPX page how do I use the NOW() function for the
InsertCommand? This doesn't seem to work...

Code snippet:
<asp:SqlDataSource ID="sdsPress" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [pressReleases] WHERE [Id] = @Id"
InsertCommand="INSERT INTO [pressReleases] ([UserId],
[PressTitle], [PressDescription], [CompanyName], [CompanyLocation],
[DateAdded], [Flagged]) VALUES (@UserId, @PressTitle, @PressDescription,
@CompanyName, @CompanyLocation, <% =Date.now() %>, 0)"
 
M

Mark Fitzpatrick

Why not just use what the database has built into it. In this case just pass
the fucntion as one of your values. For example, in SQL Server it would be
GetDate() and used like so:

.... @CompanyName, @CompanyLocation, GetDate(), 0)"

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
 
C

Cirene

That's a great idea Mark!

Mark Fitzpatrick said:
Why not just use what the database has built into it. In this case just
pass the fucntion as one of your values. For example, in SQL Server it
would be GetDate() and used like so:

... @CompanyName, @CompanyLocation, GetDate(), 0)"

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

Cirene said:
In my HTML view of my ASPX page how do I use the NOW() function for the
InsertCommand? This doesn't seem to work...

Code snippet:
<asp:SqlDataSource ID="sdsPress" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [pressReleases] WHERE [Id] = @Id"
InsertCommand="INSERT INTO [pressReleases] ([UserId],
[PressTitle], [PressDescription], [CompanyName], [CompanyLocation],
[DateAdded], [Flagged]) VALUES (@UserId, @PressTitle, @PressDescription,
@CompanyName, @CompanyLocation, <% =Date.now() %>, 0)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top