Recently I was working with Oracle Database and I found that ASP.NET Datetime causes problem as a date parameter in insert query as Oracle only takes the date value as a parameter but ASP.NET passes the Date and the Time both.
So to solve this, as a simple method i used to split the date into string format by space character i.e. (' ')
So you get the first parameter of the string array as date and other two as time.
eg.
string [] _str = Convert.ToString(_date).Split(' ');
string _strQuery = "insert into "+_strTableName+" values ('"+_name+"',"+Convert.ToDouble(_mobileno)+",'"+_company+"','"+_purpose+"','"+_department+"','"+_contactperson+"','"+_city+"','"+_str[0]+"','"+_entryperson+"','"+_exitperson+"','"+_status+"')";
return (ExecuteScalarWithPara(_strQuery));
So its just as simple as that and you are done with this problem
No comments:
Post a Comment