0

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

1 Answer 1

3

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.