Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing arguments to TO_CHAR via OLE provider

Status
Not open for further replies.

aco636

IS-IT--Management
Nov 25, 2003
212
GB
Hi All

Any help greatfully received.

Need to use TO_CHAR function but I cant get the ole provider
to pass the double quotes needed for the TO_CHAR arguments.

The error returns "Column (%d/%m/%y %T) not found in any table in the query (or SLV is undefined)."

the sql works fine using SQL editor/studio, etc but not when passed via OLE

Code:
Option Explicit

Dim cn, rc,strDSN,sql1
Set cn = CreateObject("ADODB.Connection")
Set rc =   CreateObject("ADODB.Recordset")
strDSN = "Provider=Ifxoledbc.2;Password=Password;Persist Security Info=True;" _
& "User ID=UserName;Data Source=dbname@ol_server;Extended Properties=""DB_LOCALE=en_us.819""

cn.Open(strDSN)

sql1 = "SELECT first 10 TO_CHAR(evtime,""%d/%m/%y %T"") from log"

WScript.Echo sql1
'SQL echoed out works when pasted in to SQL Editor, etc.

rc.Open sql1, cn,3,3
WScript.Echo Err.Number & " _ " & Err.Description

rc.Close
cn.Close
Set cn=Nothing
Set rc = Nothing
Set sql1 = Nothing
Set strDSN = Nothing
 
Thanks all who may have looked at this. Just worked this out - used single quote!
Doh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top