c# - SQL CONVERT function working in SQL Server but not in application -


i have following code:

… var sqlcom =             new sqlcommand("select top 1 …,convert(date,dtetme) dtetme… class c id=@id;", sqlcon); …          try         {             while (sdr.read())                 (int = 0; < 11; i++)                     rslt[i] = sdr.getvalue(i).tostring();         } 

the column dtetme of type smalldatetime in sql server 2012 database. want extract date that’s why using convert(date,dtetme) function. when run on sql server, returns date expected, in application returning default timestamp attached. don’t want this: 9/19/2013 12:00:00 am.

any idea why working in sql server , not in application?

a date date date. not string. should read as date, , format choose afterwards. database, date number - has no notion of format. so:

var when = sdr.getdatetime(i); // format when 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -