??? ????? ????? DateTime ????? ?? ???? DataSet ??? ????? ?????? ?????? ?? ??????? ???? ?? ????? ????? ??????

?????? ????????? ?????? ?????????
???? ???????: 842545 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

????? ??? ?????? ???? ????? DataSet ??? ???? ??? ???? ?? ??? ???? ??? ???? ?? ????? ????? ?????? ?? ??????? ??????? ?? ????? ?????????, ??? ????? ??????? DateTime ?? ???? ??????? ??? ????? ?????? ??????. ??? ????? ??????? DateTime ??? ????????? ???????? System.Data.DataSet ???? ??? ????? ?????? ??????? ???????? ??? ??????? ??????? ????????? ??????. ??? ???? ??????? ??? ??? ??? ????? ???? 5: 00 ?? ??????? ???? ?? ?????? ??? ???? ??? ?? ??? ???????, ???? ?????? ?? ?????? DataSet ??? 8: 00 ?? ????? ??????? ???? ???. ???? ??? ??????? ????? ?????? ??? ??? ??????? ?????? ????? ??????? ??????? ??????? ?? ????? ?????? ??? ???? ??? ? ?? ???? ??? ??????? DateTime ??? ????????? ??????. System.Data ?? ????? ??? ????? ??? class. DataSet

???????

????? ??? ??????? DateTime ??? ????? ???? System.Data.DataSet ??? ???? ??? ?? ??? ???? ??? ????. ???? ??? ??????? ????? ???? ???? ??? ?? ???? ??? ?????? ?? ????? ????? ?????? ?? ????? ??????. ??? ????? ????? ?? ???????? DateTime ??? ????? ?????? ??????? ???????? ??? ??????? ??????? ????????? ??????.

?????

??? ????? ??????? ??????? ?? ????? ???? ????? ????? ????? ???????? ??? ??? ?????? DataSet. ??? ????? ????? ?????? DataSet ??? ??? ?????? ?? ??? System.Data.DataSet ??? ??????? DateTime ??? ????? ?????? ????? ????????? ?????? ?? ????? ????? ??????.

???? ??????

??????? ?????? ??? ??? ??????? ??? ?? ??? ??????? ??????? ??????? ????? ??? ????? ?????? DataSet ?? ????? ?????? ?? ??? ???? ??? ?????? DataSet ??? ???? ?? ????? ???? ??? ????????? ??????. ?????? ????? ???? ??????? ???????:
  1. ?? ????? ???? ??? ??? ????????? ?????? ????? ??????? ?????? ??? ??? DateTime ???????? ??? ??????? ??????? ?? ????? ??????. ?????? ????? ???? ??????? ???????:
    1. ?? ?????? ????????? ???????? ??????? ?? Service1 ????? ??? ?? ???? ?? ??? "????? ???? ???": ????? ??????
      [WebMethod]
      public string AdjustDSTimeZone( DataSet dataSet ) 
      {
      
       // Obtains the time difference on the sender computer that
       //remoted this dataset to the Web service.
       string str;	
       string sourceTicksString = dataSet.ExtendedProperties["UTCDifference"].ToString();
       long sourceTicks = long.Parse( sourceTicksString );
       // Obtain the UTC offset for the remote computer.
       DateTime baseUTC = DateTime.Now;
       long UtcTickslocal = TimeZone.CurrentTimeZone.GetUtcOffset( baseUTC ).Ticks;
       // Obtain the time difference between the sender computer and the remote computer.
       long ticksDifference = sourceTicks - UtcTickslocal;
       TimeSpan timespan = new TimeSpan( ticksDifference );
       
       // The following code iterates through each table, and find all the columns that are 
       // DateTime columns. After identifying the columns that have to be adjusted,
       // it traverses the data in the table and adjusts the DateTime columns back to their 
       // original values. You must leave the RowState of the DataRow in the same state 
       //after making the adjustments.
       foreach( DataTable table in dataSet.Tables ) 
       {
        DataColumnCollection columns = table.Columns;
        int[] ColumnNumbers = new int[columns.Count];
        int   ColumnNumbersIndex = 0;
        for( int i = 0; i < columns.Count; i++ ) 
        {
         DataColumn col = columns[i];
         if ( col.DataType == typeof( DateTime ) ) 
         {	
       	ColumnNumbers[ColumnNumbersIndex] = i;
      	ColumnNumbersIndex++;
         }
       }
       foreach( DataRow row in table.Rows ) 
       {
        switch ( row.RowState ) 
        {
         case DataRowState.Unchanged:
          AdjustDateTimeValues( row, ColumnNumbers,
          ColumnNumbersIndex, timespan );
          row.AcceptChanges();	// This is to make sure that the
          // row appears to be unchanged again.
          Debug.Assert( row.RowState == DataRowState.Unchanged );
          break;
         case DataRowState.Added:
          AdjustDateTimeValues( row, ColumnNumbers, ColumnNumbersIndex, timespan );
          // The row is still in a DataRowState.Added state.
          Debug.Assert( row.RowState == DataRowState.Added );
           break;
         case DataRowState.Modified:
           AdjustDateTimeValues( row, ColumnNumbers, ColumnNumbersIndex, timespan );
          // The row is a still DataRowState.Modified.
          Debug.Assert( row.RowState == DataRowState.Modified );
          break;
         case DataRowState.Deleted:
          //   This is to make sure that you obtain the right results if 
          //the .RejectChanges()method is called.
          row.RejectChanges();	// This is to "undo" the delete.
          AdjustDateTimeValues( row, ColumnNumbers, ColumnNumbersIndex, timespan );	
          // To adjust the datatime values.
          // The row is now in DataRowState.Modified state.
          Debug.Assert( row.RowState == DataRowState.Modified );
          row.AcceptChanges();	// This is to mark the changes as permanent.
          Debug.Assert( row.RowState == DataRowState.Unchanged );
          row.Delete();			
          // Delete the row. Now, it has the same state as it started.
          Debug.Assert( row.RowState == DataRowState.Deleted );
          break;
          default:
          throw new ApplicationException
          ( "You must add a case statement that handles the new version of the dataset." );
         }
        }
       } 
       str=dataSet.Tables["MyTable"].Rows[0][1].ToString() ; 
       return str;
      }
      
      ????? AdjustDSTimeZone ??? ??? DateTime ???? ????? ?????? ?? ????? ??????. ??? ExtendedProperties ????? ??? DataSet ?????? ?? ????? ??????? "??? ??????? ???????" (UTC) ?? ?????? DataSet. ????? ???????? ??????? ExtendedProperties ????? ????????? ??????? ?? ?????? DataSet. ??? ???? ?? ???? ????? ?????? DataSet ??? ????? ????? UTC ?????? ?? ExtendedProperties ??????.
    2. ?? ?????? ????????? ???????? ??????? ????? AdjustDSTimeZone ?????:
      void AdjustDateTimeValues( DataRow row, int[] ColumnNumbers, int columnCount, TimeSpan timespan) 
      {
        for ( int i = 0; i < columnCount; i++ ) 
        {
      	int columnIndex = ColumnNumbers[i];
      	DateTime original = (DateTime)row[columnIndex];
      	DateTime modifiedDateTime = original.Add(timespan);
      	row[columnIndex] = modifiedDateTime;
        }
      }
    3. ?? ??????? ???? ???? ??? ??? ???? ???? ???????.
    4. ?? ??????? ????? ? ???? ??? ????? ???? ?????? ???????.
    ???? ????? AdjustDateTimeValues ????? ??? ???? DateTime. ???? ????? ?????? ?? ???? DateTime ?? ???? ??? ?? ????? ???????? ??? ????? ?????? ?? ????? ??????.
  2. ?? ????? ?????? ????? ????????? ???????? ??????? ?? ?? ???? ??? ??? ??? ??????? ??????? ???????. ?????? ????? ???? ??????? ???????:
    1. ?? ?????? ????????? ???????? ??????? ?? ??????? ?????? ??? ???????? ???????? ??????? ?? ??? "????? ????? ????":
      str=myDatasetService.AdjustDSTimeZone(myDataset );
      Console.WriteLine (str);
      Console.ReadLine ();
    2. ?? "??????" ???? "? ?? ?????? ???? ????????.
    3. ???? ??? ?????? ?????? ??? WebReference1 ??? ?? ???? ??? ????? ??? ????????.
    4. ?? ??????? ???? ???? ??? ??? ???? ???? ???????.
    5. ?? ??????? ????? ? ???? ??? ????? ???? ?????? ???????.
    6. ?? ??????? ????? ? ???? ??? "????" ?????? ???????.
???? ????? ?????? ?????? ?????? ???? ????? ??? ???? DateTime. ????? ???? ???? ??? ? ?????? ???? ????? DataSet ??? ????? AdjustDSTimeZone ????? ??????. ????? AdjustDSTimeZone ?? ???? ??? ?????? DateTime ?? ???? ?? ?????? ???? ???????? ??? ??????? ??????? ?? ????? ?????? ? ?? ????? ???? DateTime ???? ????? ?? ???? ??????. ???? DateTime ???? ??? ?????? ?????? ????? ?????? ?? ??? ?????? ???? ?? ??????? ?? ??? ????? ?????? ??? ????? ??????.

?????

????? ??? ?????? ??? ???????.

??????? ????

????? ????? ????? ???????

????? ???? ????? ????????

?????? ???? ????? ?????? ?? ???? Microsoft SQL Server? ???? ??????? ???????:
  1. ??? ????? "???? ??????? SQL.
  2. ?? ??????? ???? ???? ??? ????.
  3. ???? ??? ???? ????????? ???? ?? ???? ??? ?????.
  4. ?? ???? ???????? ???????? ??????? ?? ???? ?????????. ????? ??? ??? ?????? ??????.
    CREATE  TABLE MyTable (
    
                [ID] [int] NOT NULL ,
    
                [DateTimeCol] [datetime] NOT NULL 
    
    ) ON [PRIMARY]
    
    Go
    Insert into MyTable Values (1, '2004-05-19 15:00:00.000')
    Go
    
    Insert into MyTable Values (2, '2004-05-19 13:00:00.000')
    Go
    
    
  5. ?? ??????? ??????? ???? ??? ????? ?????? ?????????. ?????? ?? ????? ?????? ? ????? ?????? ?? ??????.

????? ???? ???

????? ????? ???? ??? ??? ??????? ???? ???? ????? ??? DateTime ?? ????? ????. ?????? ????? ???? ??????? ???????:
  1. ??? ????? Microsoft Visual Studio .NET.
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
  3. ??? ????? Project ? ???? ??? Visual C# ?????? ?? ???? ??? ???? ??? ASP.NET ??? ?????.
  4. ?? ?????? ?????? ???? MyWebService ??? ?? ???? ??? ?????. ?????????? ??? ????? ??? Service1.asmx.
  5. ?? "?????? ??????" ???? ??? ?????? ?????? ??? ????? Service1.asmx ?? ???? ??? ??? ????????? ????????.
  6. ?? ?????? ????????? ???????? ??????? ?? ????? ?????:
    using System.Data.SqlClient;
    using System.Timers;
  7. ??? ???? ???????? ???????? ??????? ?? Service1 ?????:
    public class Service1 : System.Web.Services.WebService
    {
  8. ?? ?????? ????????? ???????? ??????? ??? ???????? ???????? ???????? ?? ?????? 7:
    [WebMethod]
    public String DataSetReturn( DataSet clientDataSet )
    {
      string str;				
      str=clientDataSet.Tables["MyTable"].Rows[0][1].ToString() ;
      return str;	
    }
    ????? DataSetReturn ????? ???? ?? DataSet ???? ??? ??????? ?? ??? ????? ??????. ??? ??????? ?????? ???? DateTime ???? ????? ?? ???? ?????? ??? ????? ??????.
  9. ?? ??????? ???? ???? ??? ??? ???? ???? ???????.
  10. ?? ??????? ????? ? ???? ??? ???? ???? ?????? ???????.

????? ????? ????

????? ????? ???? ?????? ???? DataSet ??? ???? ??? ?????? ? ???? ??????? ???????:
  1. ??? ????? Microsoft Visual Studio .NET.
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
  3. ??? ????? Project ? ???? ??? Visual C# ?????? ?? ???? ??? ????? ???? ?????? ??? ?????.
  4. ?? ?????? ?????? ???? MyDataSet ??? ?? ???? ??? ?????. ?????????? ??? ????? ??? Class1.cs.
  5. ?? ?????? ????????? ???????? ??????? ?? ????? ?????:
    using System.Data;
    using System.Data.SqlClient;
    using System.Timers;
    using System.Diagnostics;
  6. ?? ?????? ????????? ???????? ??????? ?? ??????? ??????: ?????? ?????
    string auth="Server=YourServer;Database=YourDatabase;User ID=YourUserID;password=YourPassword";
    WebReference1.Service1 myDatasetService = new WebReference1.Service1();
    DataSet myDataset = new DataSet();
    SqlDataAdapter da = new SqlDataAdapter("Select * From MyTable",auth);
    da.Fill(myDataset, "MyTable");
    //Modify first row to have the current time.
    myDataset.Tables["MyTable"].Rows[0][1] = DateTime.Now;
    string str=myDataset.Tables["MyTable"].Rows[0][1].ToString() ;
    System.Console.WriteLine(str);
    //Store the ticks from UTC in the ExtendedProperties collection of the DataSet
    DateTime clientDateTime = DateTime.Now;
    myDataset.ExtendedProperties["UTCDifference"] = TimeZone.CurrentTimeZone.GetUtcOffset
    ( clientDateTime ).Ticks.ToString();    
    str= myDatasetService.DataSetReturn(myDataset );
    Console.WriteLine (str);
    Console.ReadLine ();
    
    ?????? ??? ?????? ??? ?????? ?? ??????? ??? ????? ??????? ?????? ???????? ????? ???????? ?? ??? ???????? ????? ?????? ??????? ????? ??????? ?? Microsoft SQL Server.
  7. ?? "?????? ??????" ???? ??? ?????? ?????? ??? ????? ??? ?? ???? ??? ????? ???? ???.
  8. ?? ?????? URL? ???? /MyWebService/Service1.asmx RemoteServer http:// ??? ?? ???? ??? ??????. ???? ???????? ?? Visual Studio .NET 2002 ? ??? ????? ???? ?????? WebReference1.

    ??????RemoteServer ?? ???? ???? ???? ?????? ?????? ??? ??? ????? ???? ???.
  9. ?? Microsoft Visual Studio .NET 2003 ? ???? WebReference1 ?? ??? ???? ??? ????. ??? ??? ??????? WebReference1 ??????? ???? ????????? ????????.
  10. ???? ??? ????? ????.
  11. ?? ??????? ???? ???? ??? ??? ???? ???? ???????.
  12. ?? ??????? ????? ? ???? ??? ???? ???? ?????? ???????.
  13. ?? ??????? ????? ? ???? ??? "????" ?????? ???????.
????? ?????? ?????? ?????? DateTime ?? ???? ?????. ???????? ???????? ??? ????? ???? DateTime ??? ??????? ?????? ?????? ????? ??????. ???? ???? DataSet ??? ???? ???. ???? ??? ????? ?????? DataSet ??????? ???? ?????? DateTime ?? ???? ????? ??? ?? ????? ?????? ??? ????? ??????. ????? ???? DateTime ???? ?? ??????? ?? ??? ???? ??? ???????? ??? ??????? ??????? ??????? ?????? ?????? ??? ?? ???? ?? "?????? ?????" ??????.

??????? ?? ???? .NET framework

??? ?? ????? ????? ??????? ?? ???? .NET Framework ?? ??????? ????? ?? ??????? ????? ???? ??? ???? ??? .NET ????? ??????? ??? ????? DataSetSurrogate.?????? ??? ??????? ?????? ??? ??? DataSetSurrogate ???? ??? ??? ??????? ?????? ?????? ?? "????? ??????? ?? Microsoft:
829740????? ???? DataSet ??????? "?" ??????? ?? ????
???? ??? DataSetSurrogate ????????? ??????? ??????? ??????? ??? ????? ??????? ??????. ???? ??? ????? ????? ???? ???? ????? ????? ?? ???? .NET Framework. ??? DataSetSurrogate ?????? ??????? ????????? ???? DataSet ?? serializes ??? DataSetSurrogate ???????? ??????? ?? ??? ?????.

?????

????? ?? ?????????? ?? ?????? ????? ????? Network (MSDN) ?????? Microsoft ???????:
System.Data.SqlClient ????? ?????
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient(vs.71).aspx
DataSet.ExtendedProperties ???????
http://msdn2.microsoft.com/en-us/library/system.data.dataset.extendedproperties(vs.71).aspx

???????

???? ???????: 842545 - ????? ??? ??????: 01/????? ??????/1428 - ??????: 1.5
????? ???
  • Microsoft .NET Framework 1.1
  • Microsoft .NET Framework 1.0
????? ??????: 
kbmt kbtshoot kbwebservices kbremoting kbclient kbsystemdata kbsqlclient kbservice kbprb KB842545 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????842545

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com