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;
}
Loading
Master BillaPosted Aug 10, 2009, 11:27 PM
The reason is you that excel sheet haven't that sheet name, so you open excel sheet manually, then look that sheets, what is the name , then use the that name to your query.
thank you
Mohamed OmarPosted Aug 10, 2009, 10:54 AM
follow the standred from the following links:
http://support.microsoft.com/kb/316934