Question : How to resolve the error "The Microsoft Jet Database Engine cannot find the input table or query" ?

My goal is to call a Sybase Stored Procedure and work with the record set that it returns, while passing it an Account Number as an input parameter. I can only call the Stored Procedure itself which I do not own and cannot update. I am trying to execute the Sybase Stored Procedure from an Access 2003 MDB file within a Command Button On Click event. The Sybase is Version 12.5.4

I execute an Access application by clicking on a Command Button and the compiler stops at the
.EXECUTE statement in my VBA code, which I placed in the ATTACH CODE SNIPPET along with the Sybase Stored Procedure I am calling.

I get a Run time error '-2147217865
The Microsoft Jet Database Engine cannot find the input table or query 'getAccountRefData'.
Make sure it exists and that it's name is spelled correctly.

I performed the following ODBC steps and received the following response from the system:
Test Connect    
Connection Established !:
--------------------------------------------------------------------------------------------------------------------------

1) Start  -->  All Programs --> Database Tools --> ODBC  DSN Creator

2) ODBC DSN Creator
    Connection Parameters
    Server                            Database                  Type
    PAP_ED_TEST1             a2query                    SYBASE

Test With ODBC Administrator  (button)

3) ODBC Data Source Administrator
User DSN tab
User Data Sources:  
Name                             Driver                                                               Add
PAP_ED_TEST1             DataDirect  4.0 Sybase Wire Protocol             Remove            
                                                                                                              Configure  <-- click on

4) ODBC Sybase Wire Protocol Driver Setup
    General tab
    Data Source Name         PAP_ED_TEST1
    Network Library Name   Winsock
    Network Address          nyuu,10467
    Database Name             a2query

    Test Connect button    <-- click on
   
    Logon to Sybase      
    Network Library                   WInsock      
    Network Address                nyuudb01,10467
    Login ID                                nitod
    Password                            ******
    Database                             a2query


Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
Here is the Sybase Stored Procedure:
 
CREATE PROCEDURE getAccountRefData
(
    @application  varchar(15),
    @accountNumber char(9),
    @accountSystem int
)
AS
 
BEGIN
/*
************************************************************************
Dynamic SQL for MDA
***********************************************************************
 
declare @execCmd varchar(250),@fixParam varchar(2000),@param1 varchar(8000)
select @fixParam = '[UniqueExecutionID ='+newid(1)+'][ServerUserID='+convert(varchar,suser_id())+'][HostName='+host_name()+']'
select @execCmd=  ' exec getAccountRefData '
select @param1 = "@application="+case when @application is null then "NULL" else "'"+rtrim(@application)+"'" end +"," +
"@accountNumber="+case when @accountNumber is null then "NULL" else "'"+rtrim(@accountNumber)+"'" end +"," +
"@accountSystem="+case when @accountSystem is null then "NULL" else rtrim(convert(varchar,@accountSystem)) end
exec('--'+@fixParam+@execCmd+@param1)
 
/////////////////////////////////////////////////////////////////////
 
select DISTINCT TA.accountNumber, TA.accountSystemRN, TA.accountStatus, TA.accountCategoryRN,countryOfCitizenship, countryOfResidence,
       TGA.fullname1, TGA.address1, TGA.city, TGA.stateCode, RN.refName, TGA.postalCode
  from rdeTAPSAccount TA,
       TAPSGeneralAddress TGA,
       TAPSCustomerDesiStreetAccount TCDSA,
       refName RN
where TA.accountNumber = TCDSA.accountNumber
  and TA.accountSystemRN = TCDSA.accountSystemRN
  and TCDSA.accountNumber = TGA.accountNumber
  and TCDSA.accountSystemRN = TGA.accountSystemRN
  and TGA.mainAddressInd = 'Y'
  and TGA.countryCode = RN.refCode
  and TA.accountNumber = @accountNumber
  and TA.accountSystemRN = @accountSystem
 
  end
**************************************
There are 4 params as follows:
 
0 -  result  -  integer
1 -  @application
2 -  @accountNumber
3 -  @accountSystem
-----------------------------------------------------------
Here is my Access VBA Code:
 
Private Sub Command9_Click()
 
Dim strApplication   As String
Dim intAccountSystemRN As Integer
Dim strAccount As String
Dim rstQueryFS As ADODB.Recordset
Dim fld As ADODB.Field
Dim intCol As Integer
Dim intRow As Integer
Dim strSQL As String
Dim com As ADODB.Command
Dim strUserName As String
Dim strValue1 As String
Dim strValue2 As String
Dim strValue3 As String
Dim recNameAdress As ADODB.Recordset
Dim cmd As ADODB.Command
 
strApplication = "test"
strAccountNumber = "004P03732"
strAccountSystem = "1435"
 
Set cmd = New ADODB.Command
 
With cmd
    .ActiveConnection = CurrentProject.Connection
    .CommandType = adCmdStoredProc
    .CommandText = "getAccountRefData"
    .Parameters.Append .CreateParameter("@application", adVarChar, adParamInput, 4, strApplication)
    .Parameters.Append .CreateParameter("@accountNumber", adVarChar, adParamInput, 20, strAccountNumber)
    .Parameters.Append .CreateParameter("@accountSystem", adVarChar, adParamInput, 4, strAccountSystem)
    .Execute <------ COMPILER STOPS HERE and generates a Runtime error.
End With
Open in New Window Select All

Answer : How to resolve the error "The Microsoft Jet Database Engine cannot find the input table or query" ?

Yeah.  Once your data types match, you should be in good shape.

AccountSystem should be an INT in VBA and in the Create Parameter statement as well.

Looks like your really close now.

Regards,
Bill
Random Solutions  
 
programming4us programming4us