Wednesday, March 7, 2012

DateTime as one parameter

I have this question in one gridview:


InsertCommand="INSERT INTO [Member] ([IC], [FirstName], [LastName], [Gender], [Birth], [Telephone], [Mobile],Email, [Address], [Postcode], [TimeOfRegistration]) VALUES (@.IC, @.FirstName, @.LastName, @.Gender, @.Birth, @.Telephone, @.Mobile, @.Email, @.Address, @.Postcode,@.TimeOfRegistration)"

If I want to insert into TimeOfRegistration with "System.DateTime.Today",

can I have some expression to replace the "@.TimeOfRegistration" in the SQL query? (<%# %>?Maybe?)

If cannot, in the parameter control below, can I put it this way to achieve it?


<asp:Parameter Name="TimeOfRegistration" Type=DateTime DefaultValue="<%# %>" />


If so, how to put it?

Thank you very much!

InsertCommand="INSERT INTO [Member] ([IC], [FirstName], [LastName], [Gender], [Birth], [Telephone], [Mobile],Email, [Address], [Postcode], [TimeOfRegistration]) VALUES (@.IC, @.FirstName, @.LastName, @.Gender, @.Birth, @.Telephone, @.Mobile, @.Email, @.Address, @.Postcode, getdate())"|||InsertCommand="INSERT INTO [Member] ([IC], [FirstName], [LastName], [Gender], [Birth], [Telephone], [Mobile],Email, [Address], [Postcode], [TimeOfRegistration]) VALUES (@.IC, @.FirstName, @.LastName, @.Gender, @.Birth, @.Telephone, @.Mobile, @.Email, @.Address, @.Postcode, getdate())"|||

Thanks Motley!

I reminds me that I should refresh some of the SQL basics which I forgot long ago^^

|||Thanks Motley It helps me a lot mate...Big Smile

No comments:

Post a Comment