Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have added in xlodbc.xla in Excel SR1 and inserted following code in to
activate worksheet Private Sub Worksheet_Activate() Dim Chan As Variant Chan = SQLOpen("DRIVER={Microsoft ODBC for Oracle};UID=username;PWD=password;SERVER=servernam e;") If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLExecQuery Chan, _ "SELECT CUST_PERSONAL_DETAILS.CUSTP_CUST_SEQNO, CUST_PERSONAL_DETAILS.CUSTP_NI_CODE FROM SUMMIT.CUST_PERSONAL_DETAILS WHERE (CUST_PERSONAL_DETAILS.CUSTP_NI_CODE=[Enter the NI Code])" If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLRetrieve Chan, ActiveSheet.Range("B3"), , , True If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLClose (Chan) End Sub Sub XLODBCErrHandler() Dim ErrMsgs As Variant Dim ErrCode As Variant ' Call SQLError to return error values to the variant ' ErrMsgs. ErrMsgs = SQLError() ' Display each item in the ErrMsgs variant array. For Each ErrCode In ErrMsgs MsgBox ErrCode Next End Sub My problem is that for some NI codes it returns no data but I know the rows exist on the oracle database. The error handling throws up no errors. I'm an oracle dba playing at using Excel for the first time and would appreciate any help you can give. -- S Boulton |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm not familiar with Oracle SQL syntax, but from my
experience, you might want to check that you are entering the Correct TYPE for the NI code. For instance, try enclosing the NI code in single quotes. -----Original Message----- Have added in xlodbc.xla in Excel SR1 and inserted following code in to activate worksheet Private Sub Worksheet_Activate() Dim Chan As Variant Chan = SQLOpen("DRIVER={Microsoft ODBC for Oracle};UID=username;PWD=password;SERVER=serverna me;") If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLExecQuery Chan, _ "SELECT CUST_PERSONAL_DETAILS.CUSTP_CUST_SEQNO, CUST_PERSONAL_DETAILS.CUSTP_NI_CODE FROM SUMMIT.CUST_PERSONAL_DETAILS WHERE (CUST_PERSONAL_DETAILS.CUSTP_NI_CODE=[Enter the NI Code])" If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLRetrieve Chan, ActiveSheet.Range("B3"), , , True If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLClose (Chan) End Sub Sub XLODBCErrHandler() Dim ErrMsgs As Variant Dim ErrCode As Variant ' Call SQLError to return error values to the variant ' ErrMsgs. ErrMsgs = SQLError() ' Display each item in the ErrMsgs variant array. For Each ErrCode In ErrMsgs MsgBox ErrCode Next End Sub My problem is that for some NI codes it returns no data but I know the rows exist on the oracle database. The error handling throws up no errors. I'm an oracle dba playing at using Excel for the first time and would appreciate any help you can give. -- S Boulton . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Used single & double quotes but still failed. For those NI codes that work
using quotes caused them to fail. Thanks anyway. Steve "Al" wrote: I'm not familiar with Oracle SQL syntax, but from my experience, you might want to check that you are entering the Correct TYPE for the NI code. For instance, try enclosing the NI code in single quotes. -----Original Message----- Have added in xlodbc.xla in Excel SR1 and inserted following code in to activate worksheet Private Sub Worksheet_Activate() Dim Chan As Variant Chan = SQLOpen("DRIVER={Microsoft ODBC for Oracle};UID=username;PWD=password;SERVER=serverna me;") If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLExecQuery Chan, _ "SELECT CUST_PERSONAL_DETAILS.CUSTP_CUST_SEQNO, CUST_PERSONAL_DETAILS.CUSTP_NI_CODE FROM SUMMIT.CUST_PERSONAL_DETAILS WHERE (CUST_PERSONAL_DETAILS.CUSTP_NI_CODE=[Enter the NI Code])" If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLRetrieve Chan, ActiveSheet.Range("B3"), , , True If IsError(Chan) Then XLODBCErrHandler Exit Sub End If SQLClose (Chan) End Sub Sub XLODBCErrHandler() Dim ErrMsgs As Variant Dim ErrCode As Variant ' Call SQLError to return error values to the variant ' ErrMsgs. ErrMsgs = SQLError() ' Display each item in the ErrMsgs variant array. For Each ErrCode In ErrMsgs MsgBox ErrCode Next End Sub My problem is that for some NI codes it returns no data but I know the rows exist on the oracle database. The error handling throws up no errors. I'm an oracle dba playing at using Excel for the first time and would appreciate any help you can give. -- S Boulton . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Boultonsj wrote ...
Used single & double quotes but still failed. For those NI codes that work using quotes caused them to fail. Thanks anyway. What is the data type? Is there a pattern to the codes that fail e.g. leading zeros, more than 16 digits, etc? Do they work if you hard code them in the sql text? Jamie. -- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
vlookup returning Errors (ISNA formula) | Excel Worksheet Functions | |||
Help on sumproduct returning errors | Excel Worksheet Functions | |||
VLOOKUP returning errors | Excel Worksheet Functions | |||
Formulas returning errors when reference columns are deleted | Excel Programming | |||
XLODBC | Excel Programming |