Hi koby
this you asked could have too much progrming but I say it to you in a summary manner
in this example I use Orders in Nortwind database and get OrdeDate as a DateTime object
then I use DateTime class for working on OrderDate
--------------------------------
//first create you connection an also yor adapter
string strConnection="server=(local);database=Northwind;i ntegrated security=true;";//optional
string strSql="select OrderID,OrderDate,ShipCountry from Orders";
SqlConnection objConnection=new SqlConnection(strConnection);
SqlDataAdapter objDataAdapter=new SqlDataAdapter(strSql,objConnection);
//then I fill mydataset object
objConnection.Open();
DataSet objDataSet=new DataSet("testData");
objDataAdapter.Fill(objDataSet,"testTable");
//here I use ItemArray formy DataRow object ,this property get or set the values for rows through an array
DateRow dr=objDataSet.Tables[0].Rows[0];
object[] t=dr.ItemArray;
DateTime dt=(System.DateTime)t[1];
//for example here t[1] has the value of the first row and second column(OrderDate)in your dataset object
//****there is something important here that the Type of t[1] is DatTime****
//then you can use DateTime properties for getting day,year,months and ....
textBox1.Text=dt.DayOfWeek.ToString();
//here you can make new table and add this variable to it
//even you can change your databse by giving new values to ItemArray property
//and then use Update method in adapter with a SqlCommandBuilder object and ....
.
.
.
objConnection.Close();
--------------------------------------------
you can expand it and do evrything you want
you should know the OrderDate(as type of SqlDateTime)become as type of DateTime when you use ItemArray property
in .NET that means there is a table map between Sqldata type and .NET data type
for example
nvarchar(sql)---------->System.string(.NET)
datetime(sql)---------->System.DateTime(.NET)
Money(sql)---------->System.Decimal(.NET)
-----------------------------------
Mahdi
|