First thing, why so:
type of date in my sql is nvarchar
Second, you can try:
Convert.ToInt32
to convert a string into interger. You can handle the conversion failure as Overflow or Format exception.
Ex:
int convertedInteger = Convert.ToInt32("someString");
Refer:
MSDN: Convert.ToInt32 Method (String)[
^]
UPDATE:
my field in sql is nvarchar and i want send date like 12/02/2012 to related field in sql
Your code already have most of it. To have a defined date format sent as a string to a Varchar field:
int pyear = p.GetYear(mdate);
int pmonth = p.GetMonth(mdate);
int pday = p.GetDayOfMonth(mdate);
string pdate = string.Format("{2}/{1}/{0}", pyear, pmonth, pday);