Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,

I have a windows based C# application. When I try to input details in login page, it shows the error below.

 private void button1_Click(object sender, EventArgs e)
        {

            try
            {


                con.ConnectionString = Microsoft.VisualBasic.Strings.Trim(obj.connection().ToString());
                con.Open();
                string qry;
                qry = "select * from admin";
                OdbcCommand cmd = new OdbcCommand(qry, con);
                OdbcDataAdapter ad = new OdbcDataAdapter();
                DataSet ds = new DataSet();
                ad.SelectCommand = cmd;
                ds = new DataSet();
                ad.Fill(ds, "admin");  
//here it direct goes to catch block 

catch (Exception ex)
            {



and shows -----

ERROR [42S02] [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'admin'. Make sure it exists and that its name is spelled correctly.


Please help to solve the issue

Thanks & regards

Indrajit
Posted
Updated 1-May-11 20:28pm
v2

Hi, try to check the value of your connection string, the error seems to reside on either the connectionstring missing, or invalid database specified on your connectionstring.

Good luck!
 
Share this answer
 
Comments
IndrajitDasgupat 2-May-11 2:32am    
how can I check the connection string please help
Pong D. Panda 2-May-11 2:36am    
try putting a breakpoint on the line 'con.Open();' Or do what digital man suggest, put bracket on your select query. Use "select * from [admin]" on your statement.
IndrajitDasgupat 2-May-11 2:38am    
How can I check the path of DB from my project
Please help
IndrajitDasgupat 2-May-11 2:43am    
Thank U Sir it is working
Pong D. Panda 2-May-11 2:52am    
Then mark this question as solved and it would be helpful if you vote up the answer that helped you.
Good luck!
The clue is in the exception message: looks like you are connecting but Access can't find a table called 'admin'. Does your database contain a table called 'admin'? Long time since I used Access but try this statement: select * from [admin].
 
Share this answer
 
Comments
IndrajitDasgupat 2-May-11 2:37am    
Yes my DB contain table "admin"
How can I check the path of DB from my project
Please help
R. Giskard Reventlov 2-May-11 2:43am    
Th epath should be in your connection string. Try putting the db in the same folder as the application so that the path becomes moot and ensure that you have the requisite permissions to open the database: can't help more as it is many years since I played with Access.
There is a mistake about your admin table because you dont have a table named admin.Check your tablename and Table.Also check your connection string it's syntax should be like this :
string bglnyer = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\DATABASE.mdb";
 
Share this answer
 
v3
dont use admin as second parameter

u can do like this

MIDL
ad.Fill(ds)


try with this
 
Share this answer
 

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