none
I m retriving value from excel file using oledb Connection RRS feed

  • Question

  • Hi,

    I m retriving value from excel file using oledb Connection and inserting those valuwe in Excel file using SqlConnection

    Now In Excel sheet v hv Date Column .

    I retrive value

    DateTime Dt=Convert.ToDatetime(ds.tablesTime.rows[0]["DoneDate"]);

    now In

    insert query

    insert into table1 (duv_DaoneDate) values (@Dt);

    Bt on

    cmd.ExecuteNonQuery () It is giving Error.

    The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

    Cn u help me Plzzz

    I hv change formate of Column of Excel also.

    Plzzz help me

    I M Writting Code In C#.

     

    Plzzz I need ur help tooo much

    Regards,

    Pady123

     

     

    Wednesday, August 1, 2007 11:37 AM

All replies

  • What is your connection string to the Excel file? Does it contain IMEX=1 property? If yes, then all the values retrieved from Excel as strings and it is quite possible that dates are in a different format than your regional settings. To retrieve values in native format in this case you need to remove IMEX=1 from the connection string. But it is possible you will get dates as float numbers in this case

    Thursday, August 2, 2007 9:53 AM
    Moderator
  • Thanks a lot for ur reply .

    But now i hv one more issue

    cn u help me plzz

     

    I hv to create datagrid with two additional column i.e. it should contain dropdownlist in first column n textbox in last column. n on selected index change i hv to diplay textbox.Initialy text box ll nt b visible.

    So for that i created two template for dropdownlist n textbox n i bind datagrid with database at run time

    No when i m ching the value of drop down list (i.e. index is changing) then my drop downlist n textbox gets diappeared from datagrid n other records remain same. i.e. data from database is comming but templates r not .

     

    Plzzz help me its really very urgent.

     

    Pady,

    Wednesday, August 22, 2007 3:30 PM
  • I have seen your another post regarding datagrid and I have moved it to appropriate forum.

    Thursday, August 23, 2007 1:45 AM
    Moderator