6

How Can I map "timestamp with time zone" datatype from postgreSql to System.Data.DbType I need to pass parameter as it will go to the column which has "timestamp with time zone"

following is my code:

var pOrderDate = cmdOrder.CreateParameter();
pOrderDate.ParameterName = "OrderDate";
pOrderDate.DbType = System.Data.DbType.DateTime;
pOrderDate.Value = objOrder.OrderDate;
cmdOrder.Parameters.Add(pOrderDate);

Following line causes problem:

pOrderDate.DbType = System.Data.DbType.DateTime;
shubhangi Motling
  • 282
  • 1
  • 4
  • 12
  • 9
    @Freelancer please speak English. – Bart Friederichs Apr 05 '13 at 10:35
  • This is my c# code..I need to map through my program. – shubhangi Motling Apr 05 '13 at 10:37
  • @Freelancer why do you ingore the forum rules? – MikroDel Apr 05 '13 at 11:26
  • @MikroDel I know you are very good person , but in which language you will speak if any Bangladeshi[Tamar Badi] meets you?? – Freelancer Apr 05 '13 at 11:29
  • @Freelancer Ill use English in this forum. – MikroDel Apr 05 '13 at 11:30
  • @MikroDel you are saying this just for debate, I know you will speak in Bengali. She (Poster) is marathi thats why i used Marathi language. – Freelancer Apr 05 '13 at 11:33
  • 1
    @Freelancer - if you not agree to use English in this forum - find other place for your converastion. – MikroDel Apr 05 '13 at 11:35
  • @Freelancer - your problem is that you ingore the rules of this forum. – MikroDel Apr 05 '13 at 11:38
  • @MikroDel yeah , i know that English is primary language which should be used , but i can do anything for this. can you provide me link of the FAQ or rule where it is written that use only english. please i want to revise those rules. – Freelancer Apr 05 '13 at 11:44
  • 1
    @Freelancer - http://blog.stackoverflow.com/2009/07/non-english-question-policy – MikroDel Apr 05 '13 at 11:49
  • @MikroDel wrtten no where that you MUST use English. – Freelancer Apr 05 '13 at 11:59
  • @Freelancer - read also this one: http://meta.stackexchange.com/questions/40271/shouldnt-the-english-only-policy-be-mentioned-in-the-faq – MikroDel Apr 05 '13 at 12:08
  • @Freelancer - questions asked not in Eglish will be deleted. The same with the comments - they will be flaged from other users - and than deleted. Thats why your and shubhangi Motling comments written not in English will also be delted from moderators. – MikroDel Apr 05 '13 at 12:10
  • @MikroDel Its all about asking questions, nothing about comment, i can also understand use of english about answers, but its not written about comments. Its all about "asking" questions in English. – Freelancer Apr 05 '13 at 12:12
  • @Freelancer - will see - if your not english comments will not be deleted - than you are right. If they will be - you are not. – MikroDel Apr 05 '13 at 12:15
  • @Freelancer - they are already deleted. You was wrong. If you have such a question "Is it possible to write some non english comments?" post in on http://meta.stackoverflow.com/ please. – MikroDel Apr 05 '13 at 12:17
  • @Freelancer - "Yeah , i am already doing that." - and where is your question on meta.stackoverflow.com ? – MikroDel Apr 05 '13 at 12:22
  • yeah just texting it, dont worry i will definitely post it, and also post you link of it. – Freelancer Apr 05 '13 at 12:23
  • @Freelancer - ok - it make sense to have it clear – MikroDel Apr 05 '13 at 12:24
  • @MikroDel just tell me which tag i should use for this question? i am new for it. – Freelancer Apr 05 '13 at 12:28
  • 1
    let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/27633/discussion-between-mikrodel-and-freelancer) – MikroDel Apr 05 '13 at 12:29
  • Can you add the definition of `cmdOrder` to your code? – Ryan Gates Apr 10 '13 at 02:34

1 Answers1

2

Have you considered trying the DateTimeOffset class in .NET?

I'm unaware of how it maps to Postgres "DateTime with Timezone" type, but it has a 1:1 correlation with what I believe would be the MSSQL equivalent (also called DateTimeOffset).

Note that the naming here is quite poor - the type represents a DateTime + Offset, and not just the Offset itself.