Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default DSN Connection with OpenRecorset

Hello,

I am trying to write code that will define the ODBC connection. No problem
there.
I have created a workspace and then defined the connection to use my user ID
and password (to allow other to access data otherwise not available).

My problem is that my SQL that works if I have a regular database object and
openrecordset object no longer works. Do I have to modify the SQL since I am
using a connection object in place of the database object?

The changes that I am aware of is that Access will append the database name
to the beginning of the table.field string ( example: myTABLE.fieldname now
looks like dbMYDATABSE_myTABLE.fieldname).

I have a condition in my SQL on a field that houses dates. In my code that
portion of the SQL looked like ..."(mydatabase_mytable.OOSDATE Date() )"
This worked just fine for the past few weeks. But now that I have defined
the connection and tit gives me a runtime error "3146 ODBC--Call Failed"


I have done a simple query on another database table and the connection
object worked fine.
Can anyone help?

Thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default DSN Connection with OpenRecorset

James,
If you are using Access, you can test the SQL in the new query in Access to
see if the syntax is correct and you get the correct results.
One thing I see is that you are using dates. Does it help if the dates are
surrounded by "#" and evaluate Date() before you execute the query. So I
would change your query to:
.....mytable.OOSDATE #" & Date() & "#"

If would if you post your connection string and code.

NickHK

"James McDowell" wrote in message
...
Hello,

I am trying to write code that will define the ODBC connection. No

problem
there.
I have created a workspace and then defined the connection to use my user

ID
and password (to allow other to access data otherwise not available).

My problem is that my SQL that works if I have a regular database object

and
openrecordset object no longer works. Do I have to modify the SQL since I

am
using a connection object in place of the database object?

The changes that I am aware of is that Access will append the database

name
to the beginning of the table.field string ( example: myTABLE.fieldname

now
looks like dbMYDATABSE_myTABLE.fieldname).

I have a condition in my SQL on a field that houses dates. In my code

that
portion of the SQL looked like ..."(mydatabase_mytable.OOSDATE Date() )"
This worked just fine for the past few weeks. But now that I have defined
the connection and tit gives me a runtime error "3146 ODBC--Call Failed"


I have done a simple query on another database table and the connection
object worked fine.
Can anyone help?

Thank you



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default DSN Connection with OpenRecorset

Nick, Thanks for the reply. I kept on playing with the SQL and found that I
had to encase the date in single quotes. I am now stuck on another query. I
will submit a new post.

Thank you,
Jim

"NickHK" wrote:

James,
If you are using Access, you can test the SQL in the new query in Access to
see if the syntax is correct and you get the correct results.
One thing I see is that you are using dates. Does it help if the dates are
surrounded by "#" and evaluate Date() before you execute the query. So I
would change your query to:
.....mytable.OOSDATE #" & Date() & "#"

If would if you post your connection string and code.

NickHK

"James McDowell" wrote in message
...
Hello,

I am trying to write code that will define the ODBC connection. No

problem
there.
I have created a workspace and then defined the connection to use my user

ID
and password (to allow other to access data otherwise not available).

My problem is that my SQL that works if I have a regular database object

and
openrecordset object no longer works. Do I have to modify the SQL since I

am
using a connection object in place of the database object?

The changes that I am aware of is that Access will append the database

name
to the beginning of the table.field string ( example: myTABLE.fieldname

now
looks like dbMYDATABSE_myTABLE.fieldname).

I have a condition in my SQL on a field that houses dates. In my code

that
portion of the SQL looked like ..."(mydatabase_mytable.OOSDATE Date() )"
This worked just fine for the past few weeks. But now that I have defined
the connection and tit gives me a runtime error "3146 ODBC--Call Failed"


I have done a simple query on another database table and the connection
object worked fine.
Can anyone help?

Thank you




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
always recheck data connection library for latest connection strin FurmanGG Excel Discussion (Misc queries) 0 September 14th 07 04:48 PM
no DDE connection?? askmiller Excel Discussion (Misc queries) 0 August 5th 06 09:19 PM
ADO Connection Alex Excel Programming 12 May 5th 06 07:26 PM
ADO Connection Help Matty G Excel Programming 3 June 23rd 05 02:14 PM
SQL Connection Adul Excel Programming 0 November 4th 04 08:24 AM


All times are GMT +1. The time now is 11:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"