Compare datatypes, colum names...

Last post 09-20-2008 6:53 AM by Davidnyh. 2 replies.

Sort Posts:

  • Compare datatypes, colum names...

    08-17-2008, 8:58 AM
    • Member
      207 point Member
    • Davidnyh
    • Member since 05-10-2005, 3:37 PM
    • Posts 70

     Hi

    I have two questions.

    First:

    How can I compare the datatypes and column names from two datatables? One is filed from excel and the other one is from a database.

     Second:

    How can I make a method that insert all the records from a datatable that cancel the inserted records as soon a value from a record is wrong for examle characters in an integer field. Or skip the record.

    Thanks

    Davidnyh

  • Re: Compare datatypes, colum names...

    08-20-2008, 11:38 PM

    Hi Davidnyh,

    How can I compare the datatypes and column names from two datatables? One is filed from excel and the other one is from a database.

    You can get the name and type by the index of a certain column in this way - since you've got the two stings, you can compare them easily:

    string name = ds.Tables[0].Columns[0].ColumnName;  // e.g. "col1"
    string ty = ds.Tables[0].Columns[0].DataType.ToString(); // e.g. "System.Int32"

     

    How can I make a method that insert all the records from a datatable that cancel the inserted records as soon a value from a record is wrong for examle characters in an integer field. Or skip the record.

    Could you clarify it? I can't understand your meaning.

    Thanks. 

    David Qian
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Compare datatypes, colum names...

    09-20-2008, 6:53 AM
    • Member
      207 point Member
    • Davidnyh
    • Member since 05-10-2005, 3:37 PM
    • Posts 70

    Thanks for your answer.

     When I have an excel file with a column that needs to holds only integers but one row has a character the method need to have an option to skip this row and log the skipped row in a textbox after adding all to other corrected rows.

     Thanks.

Page 1 of 1 (3 items)