Showing posts with label member. Show all posts
Showing posts with label member. Show all posts

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

Tuesday, February 14, 2012

date/time format with Format_string is not working

with member x as [Date].[Calendar].CurrentMember.Name, format_string = 'mm/yyyy'

select x on 0 ,

[Date].[Calendar].[Date].AllMembers on 1

from [Adventure Works]

When I run this, I get the same value as CurrentMember.name for 'x'. Any ideas?

The .Name is not of type date - instead use .MemberValue:

with member x as [Date].[Calendar].MemberValue, format_string = 'mm/yyyy'

select x on 0 ,

[Date].[Calendar].[Date].Members on 1

from [Adventure Works]