excel+oledb+datatype+integer and text in a same column

hi,

i am populating my datagridview with oledb connection with ms excel. the data in my excel file is in unmanage format. means one column, named "col1" contains text and integer data type as well. the problem i am having is that the data in grid doesnt show integer values in grid which actually exists in "col1" in excel file. i have used odbc connection as well.

the sample view is as follows:

excel sheet(actual data):

col1 col2 col3

turbo 2 1

one 2 3

45 yo 8

three 45 23

and the data shown in grid view is as follows:

datagridview:

col1 col2 col3

turbo 2 1

one 2 3

8

three 45 23

i think this is the problem of datatype.can anyone please guide me how to resolve this issue.

[877 byte] By [measum] at [2007-12-24]
# 1

You need to add "IMEX=1" to the Extended Properties part of the OleDb connection string:

string oleConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\OleDbTest.xls;"
+
"Extended Properties=\"Excel 8.0;IMEX=1\"";

Then all values will be read as String.

MarkRendle at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# General...