Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
exception in connecting the xls file in C# ASP .net
Deepak Goyal
15y
4.5k
1
Reply
I an facing a problem if some one can help it will be greate.
I have a XLS file as a database from which I want to get data.
But every time VS 2005 comes out with an exception
The
Microsoft
Jet database engine could not find the object 'user_account$'. Make sure the object exists and that you spell its name and the path name correctly.
my code is as below
public int verify_user(string filename, string user_passed)
{
String connectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + filename + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
OleDbCommand selectCommand = new OleDbCommand("SELECT * FROM [user_account$]", connection);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
dataAdapter.SelectCommand = selectCommand;
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
connection.Close();
DataTable dataTable = dataSet.Tables[0];
int cols = dataTable.Columns.Count;
int rows_count= dataTable.Columns.Count;
return rows_count;
}
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to convert amount in word
Old textbox.lostfocus in C# 3.0 FRamework 3.5