How to convert c# datetime into oracle timestamp? -


i trying store c# datetime oracle database timestamp storing without problems, when trying select data database particular date giving me error not valid month..

datetime sessiondate =datetime.now(); int userid_int = 101; string usertypeis ='engineer';  string get_log_query = "select log_id jointing_login_log user_id="+userid_int+" , user_type='"+usertypeis+"' , session_start='"+sessiondate+"'"; 

string get_log_query = "select log_id jointing_login_log user_id="+userid_int+" , user_type='"+usertypeis+"' , session_start='"+sessiondate+"'"; 

you should never use string concatenation building queries parameters. parameterized queries faster , avoid sql injection , troubles type conversion. if session_start timestamp, code -

string get_log_query =      @"select log_id          jointing_login_log         user_id= :user_id           , user_type= :user_type           , session_start= :session_start";   cmd.parameters.add("user_id", oracledbtype.decimal, userid_int, parameterdirection.input);  cmd.parameters.add("user_type", oracledbtype.varchar2, usertypeis, parameterdirection.input);  cmd.parameters.add("session_start", oracledbtype.timestamp, sessiondate, parameterdirection.input); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -