views:

38

answers:

1

Hello everyone.

In the program I'm currently working on, my table has a Create_Timestamp column, which I defined as timestamp.

When I'm working with my data context and my form values in my controller on the HttpPost, I'm trying the following:

NewsArticle article = new NewsArticle();
article.Create_Timestamp = System.DateTime.Now;

The error I get is Cannot implicitly convert from 'System.DateTime' to 'System.Data.Linq.Binary'

I've tried to force the conversion, but I'm unsure exactly what I'm doing at this point.

Is it possible in C# to do this conversion and still have Linq be happy with me?

Thanks

+2  A: 

I am guessing you are using the SQL timestamp type in your table and you are expecting it to be a DateTime. Timestamp isn't really meant for holding Date/Time information. From MSDN (http://msdn.microsoft.com/en-us/library/aa260631(SQL.80).aspx):

timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.storage size is 8 bytes.

Change your column "Create_Timestamp" to DateTime and you should be fine.

MarkisT
This seemed to work. Thanks.
Joe Morgan