Excel Transfert

  • Thread starter Thread starter lukas
  • Start date Start date
L

lukas

When i try to import excel data with Oledb. The column
who have number value and blank value is not im my
dataset.
For the importation i do
OleDbDataAdapter oCmd=new OleDbDataAdapter("SELECT * FROM
[sheet1$]",strCn);
DataSet oDS=new DataSet();
try
{
oCmd.Fil(oDS,"ExcelInfo");
dataGrid2.DataSource=oDS.Tables[0];
}
Could give me an answer. What can i do in my code for
having this column.

Lukas
..
 
¤ When i try to import excel data with Oledb. The column
¤ who have number value and blank value is not im my
¤ dataset.
¤ For the importation i do
¤ OleDbDataAdapter oCmd=new OleDbDataAdapter("SELECT * FROM
¤ [sheet1$]",strCn);
¤ DataSet oDS=new DataSet();
¤ try
¤ {
¤ oCmd.Fil(oDS,"ExcelInfo");
¤ dataGrid2.DataSource=oDS.Tables[0];
¤ }
¤ Could give me an answer. What can i do in my code for
¤ having this column.

If I understand your question, it sounds like you're getting a null value when using mixed data
types in a column. Try adding the IMEX argument to your connection string

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
'"Data Source=D:\My Documents\Book2.xls;Extended Properties=""Excel
8.0;HDR=NO;IMEX=1;"""


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
¤
¤ Thanks for your answer
¤

Since I noticed you are using C#, here is the syntax I should have posted:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=d:\\My Documents\\Book2.xls;" +
"Extended Properties=" + (char)34 + "Excel 8.0;HDR=NO;IMEX=1;" + (char)34;


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top