Solved

Issues using ADODB connection to DB2 table

Posted on 2008-10-27
5
385 Views
Last Modified: 2013-11-27
Hello,

I'm having troubles connecting to a DB2 table (or setting up the ADODB connection) It works fine when I'm hitting an access table, but for some reason will not work with the DB2 table. The table, of course is linked via ODBC and I can connect to it when running an Access query. I'm trying to populate a single text box on a form with a count derived from the following query. I'm getting the error message: "Run-time error "-2147217565(80040e37) [IBM][CLI Driver][DB2] SQL0204N "DIW07.PROD_VLTC900A_CLM" is an undefined name. SQLSTATE=42704.

The only thing i can think of is that it's taking my username "DIW07" and using it as the database name? I'm not sure why this would be an issue as the table is linked... it's a real pain... Any help would be HUGELY appreciated!


Here is the code I'm using:



Private Sub CalcKim_Click()

Dim rsActivity As ADODB.Recordset

Dim cnUDB As ADODB.Connection

Set cnUDB = New ADODB.Connection

With cnUDB

.Provider = "MSDASQL"

.ConnectionString = "Data Source=db2psn"

.Properties("Prompt") = adPromptCompleteRequired

.Open

End With
 
 

'0-30 days

sSQL = ""

sSQL = sSQL & "SELECT Count(I_SYS_CLM)AS thirtydayKim "

sSQL = sSQL & "FROM PROD_VLTC900A_CLM p INNER JOIN Teams t ON p.Custodian = t.CustodianID "

sSQL = sSQL & "WHERE p.PendingStatus = 'PC' And t.Manager = 'Kim' "

'And DateDiff('d',[DatePending],Date()) <=30"

Set rsActivity = New ADODB.Recordset

With rsActivity

.CursorType = adOpenForwardOnly

.CursorLocation = adUseServer

.LockType = adLockReadOnly

.Open sSQL, cnUDB

End With

Me.k2 = rsActivity!thirtydayKim

Open in new window

0
Comment
Question by:c9k9h
  • 3
  • 2
5 Comments
 
LVL 42

Expert Comment

by:dqmq
ID: 22813454
>The only thing i can think of is that it's taking my username "DIW07" and using it as the database name?

It's using DIW07 as the database owner or schema name.  

But no matter, if you have links to PROD_VLTC900A_CLM and teams tables, then you are going after the count the wrong way.   Store your join in a query:

    SELECT * FROM PROD_VLTC900A_CLM p INNER JOIN Teams t ON p.Custodian = t.CustodianID


and then retrieve it:

me.k2=  DCOUNT("I_SYS_CLM","YOURQUERYNAME","PendingStatus = 'PC' And t.Manager = 'Kim'")
0
 

Author Comment

by:c9k9h
ID: 22813520
Okay,

So you are saying create an access query with SELECT * FROM PROD_VLTC900A_CLM p INNER JOIN Teams t ON p.Custodian = t.CustodianID  and then call it in the code?
0
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 22813573
Yes, access the data through the linked tables instead of an ADO connection
0
 

Author Comment

by:c9k9h
ID: 22813621
Okay,

So I've created a query that selects all of the data and joins the two tables. For the On_click event of the command button i've gotten rid of all of the code and just have:

Me.k2 = DCount("I_SYS_CLM", "qryDB2", "C_STA_CLM = 'PC' And Teams.Manager = 'Kim'")

Now when I run, I get the error "Run Time error 2001 - you canceled the previous operation" and it highlights the me.k2 line. It will not even prompt for the connection to the DB2 table.
0
 

Author Comment

by:c9k9h
ID: 22814137
Got it!

simple fix... needed to get rid of the "Teams." seeing as I'm pulling from an existing query.


Thanks a bunch!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now