D
Dig314
I am connecting to ORACLE through ADO and Excel 2002 VBA.
My SELECT statement works in MS-ACCESS SQL because it understands the
LEFT function. It does not work using VBA and ADO because it thinks
the column name is "LEFT(user_id,2)":
SELECT * FROM CO20.co_table WHERE LEFT(user_id,2) = 79
This is the error message:
Run-time error '-2147217900(80040e14)':
ORA-00904: invalid column name
How can rewrite this statement to work with LEFT or produce the same
results without that function ?
Thanks for the help.
Dig
*************************************************************************
Public adoConn As New ADODB.Connection
Public adoCmd As New ADODB.Command
Public adoRS As New ADODB.Recordset
Public Const strConnection = "Provider = MSDAORA;Data Source =
server;user ID = ID; password = PASS"
Public Const strRS = _
" SELECT * FROM CO20.co_table WHERE left(user_id,2) = 79 "
sub Main()
Call ReturnRecordSet(strRS)
End Sub
Sub ReturnRecordSet(strRSOpen As String)
Set adoConn = New ADODB.Connection
Set adoRS = New ADODB.Recordset
adoConn.ConnectionString = strConnection
adoConn.Open
adoConn.CursorLocation = adUseClient
adoRS.ActiveConnection = adoConn
adoRS.Open strRSOpen
End Sub
*************************************************************************
My SELECT statement works in MS-ACCESS SQL because it understands the
LEFT function. It does not work using VBA and ADO because it thinks
the column name is "LEFT(user_id,2)":
SELECT * FROM CO20.co_table WHERE LEFT(user_id,2) = 79
This is the error message:
Run-time error '-2147217900(80040e14)':
ORA-00904: invalid column name
How can rewrite this statement to work with LEFT or produce the same
results without that function ?
Thanks for the help.
Dig
*************************************************************************
Public adoConn As New ADODB.Connection
Public adoCmd As New ADODB.Command
Public adoRS As New ADODB.Recordset
Public Const strConnection = "Provider = MSDAORA;Data Source =
server;user ID = ID; password = PASS"
Public Const strRS = _
" SELECT * FROM CO20.co_table WHERE left(user_id,2) = 79 "
sub Main()
Call ReturnRecordSet(strRS)
End Sub
Sub ReturnRecordSet(strRSOpen As String)
Set adoConn = New ADODB.Connection
Set adoRS = New ADODB.Recordset
adoConn.ConnectionString = strConnection
adoConn.Open
adoConn.CursorLocation = adUseClient
adoRS.ActiveConnection = adoConn
adoRS.Open strRSOpen
End Sub
*************************************************************************