Click here to Skip to main content
15,923,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre lang="cs">string excelConnectionString = @&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Deneme.xls;Extended Properties=&quot;&quot;Excel 8.0;HDR=YES;&quot;&quot;&quot;;
using (OleDbConnection connection =
new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand
(&quot;Select id,data FROM [Sheet1$]&quot;, connection);
connection.Open();
// Create DbDataReader to Data Worksheet
using (DbDataReader dr = command.ExecuteReader())
{
// SQL Server Connection String
string sqlConnectionString = "";

// Bulk Copy to SQL Server
using (SqlBulkCopy bulkCopy =
new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.DestinationTableName = &quot;ExelData&quot;;
bulkCopy.WriteToServer(dr);
}
}</pre>


Where is my problem

Error Message:<pre lang="msil">System.Data.SqlClient.SqlException: Invalid object name &#39;ExelData&#39;.</pre>

but my database name is ExelData what is the problem

can I help you<b></b>
Posted

1 solution

Be sure,
C++
bulkCopy.DestinationTableName

Contains your database table name not a database name.

Correct it and try.
 
Share this answer
 
Comments
Sandeep Mewara 25-May-11 10:52am    
Comment from OP:
Sorry, I wrote the wrong,

my table name is ExelData

Whats teh problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900