Click here to Skip to main content
15,887,966 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I am trying to connect DB2 database in my application I get this error:

"ERROR [42704] [IBM][DB2/NT] SQL0204N "DB2ADMIN.TBL_USER" is an undefined name."


Please help me on solving this error.

C#
string connString = "Database=dbName;userID=usrname;password=pass server=servername";

using (DB2Connection con = new DB2Connection(connString))

            {

                DB2Command cmd = new DB2Command("SELECT * FROM TBL_USER", con);

                DataTable dTable = new DataTable();

                DB2DataAdapter adapter = new DB2DataAdapter(cmd);

                adapter.SelectCommand = cmd;

                adapter.Fill(dTable);  //Error is executed here.

                return dTable;

            }
Posted
Comments
[no name] 15-Oct-12 9:36am    
And do you have a table named TBL_USER in your DB2ADMIN database?
Anele Ngqandu 15-Oct-12 9:39am    
yes i do sir

1 solution

I'd guess that the table does in user DB2ADMIN's schema. Try something like this:

DB2Command cmd = new DB2Command("SELECT * FROM dbo.TBL_USER", con);


Where dbo shall be substituted for the schema your table TBL_USER is really in.

Regards,

— Manfred
Might want to read some about schemas: http://publib.boulder.ibm.com/infocenter/zos/basics/index.jsp?topic=/com.ibm.db2z.doc.intro/db2z_schemaqualifiers.html[^]
 
Share this answer
 
v2
Comments
Anele Ngqandu 15-Oct-12 9:49am    
i am still geting the same error sir
Manfred Rudolf Bihy 15-Oct-12 10:23am    
I wrote: "Where dbo shall be substituted ..." Is there anything unclear about that?
Since I can't see your computer screen you'll have to find out yourself what schema TBL_USER belongs to. Why don't you ask your database administrator?
Anele Ngqandu 15-Oct-12 10:27am    
I get what you saying sir and I did what you told me to but i get the same results.There is no database administrator am just playing with DB2 here. Am assuming it has to do with privileges thou.
Anele Ngqandu 16-Oct-12 2:26am    
Ow my bad,wrote wrong schema name.

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