Yashu here


hi,

Here is brief description of Error.

I'm trying to copy data from Excel sheet into data base(SQL Server ) using OLEDB Driver ( Root cause of all my head ache)

my code looks like below,

------------------------------------------------------------------------------------------------------------------

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=D:\\FLI_USER_DETAILS.xls;" + "Extended Properties=" + "Excel 10.0;" + "HDR=Yes;" + "IMEX=1";

//(NOTE i have tried with all versions in Extended properties like 8.0 ,11.0 etc)

string queryString = "SELECT * FROM [FLI_USER_DETAILS$]";

connection = new System.Data.OleDb.OleDbConnection(connectionString);

using (connection)

{

OleDbCommand command = new OleDbCommand(queryString, connection);

try

{

connection.Open();// After executing this line i get the error Could not find installable ISAM

}

catch (Exception exExcel)

{

Response.Write("Error while opening" + exExcel.Message);

}

------------------------------------------------------------------------------------------------------------------

I tried by registering all related DLLs

I'm using : OS - Vista,VisualStudio2005,DotnetFramework 2.0,

Pls any one help me to solve this problm

Thanks in advance

Yash






Re: "Could not find installable ISAM." in VISTA

CetinBasoz

Maybe it is because you removed the quotes from extended properties. As far as I know they're crucial. Here is a sample code I used before successfully:

Code Snippet

using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;

class xlAppendFromSample
{
static void Main()
{
string strSource = "Provider=Microsoft.Jet.OLEDB.4.0;"+
"Data Source=c:\\temp\\sample.xls;Persist Security Info=False;Extended Properties=\"Excel 8.0\"";
string strTarget = "Data Source=.\\SQL2005;Initial Catalog=test;Integrated Security=True";

OleDbConnection conSource = new OleDbConnection(strSource);
OleDbCommand cmd = new OleDbCommand("select * from [sheet1$]", conSource);
conSource.Open();
OleDbDataReader rdr = cmd.ExecuteReader();
SqlConnection conTarget = new SqlConnection(strTarget);
SqlBulkCopy cpy = new SqlBulkCopy(conTarget);
conTarget.Open();
cpy.DestinationTableName = "dbo.Location";
cpy.ColumnMappings.Add(0, "[Name]");
cpy.ColumnMappings.Add(1, "[CostRate]");
cpy.ColumnMappings.Add(2, "[Availability]");
cpy.ColumnMappings.Add(3, "[ModifiedDate]");
cpy.WriteToServer(rdr);
conTarget.Close();
rdr.Close();
conSource.Close();
cpy.Close();
}
}






Re: "Could not find installable ISAM." in VISTA

DCSteele

When declaring connections in a config file, you need to put single quotes around the Data Source, AttachDbFilename & Extended Properties sections of your connection string. For example...

connectionString="Data Source='.\SQLEXPRESS';AttachDbFilename='C:\mydb.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True"

connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\myxl.xls';Extended Properties='Excel 5.0;HDR=Yes;IMEX=1' "