Shivshankar
asked on
Dr. Watson error while opening a recordset
Well.. here's the problem. I use VBA for some automation purposes. My back-end is SQL Server. I build a query using the user-inputs(like table-name, DSN name etc).
My code runs like this...
Set wrkODBC = CreateWorkspace("", "user", "", dbUseODBC)
Set conDB = wrkODBC.OpenConnection("cn Connect", dbDriverNoPrompt, , "ODBC;DATABASE="+strDataba se+";UID=u ser;PWD=;D SN=" + strODBCDriver)
Set rs = conDB.OpenRecordset(strQue ry, dbOpenSnapshot)
All's well until the last statement. I debugged, and when I pressed F8 on the line Set rs = ..., Dr. Watson error got thrown and Excel closed.
Pls. note that the query that I build in strQuery references the tables - syscolumns and sysobjects - read-only tables for this user.
Any help is appreciated.
======
Shiva.
======
My code runs like this...
Set wrkODBC = CreateWorkspace("", "user", "", dbUseODBC)
Set conDB = wrkODBC.OpenConnection("cn
Set rs = conDB.OpenRecordset(strQue
All's well until the last statement. I debugged, and when I pressed F8 on the line Set rs = ..., Dr. Watson error got thrown and Excel closed.
Pls. note that the query that I build in strQuery references the tables - syscolumns and sysobjects - read-only tables for this user.
Any help is appreciated.
======
Shiva.
======
ASKER
burintje,
To answer your questions:
1. Yes, the DSN is available in my system.
2. >>What you also could try is to set all the parts in the connection string bit by bit
Well, It was like that in the code. But, to make it look short here, I concatenated everything in one-line.
3. Yes, this is a code taken from my EXCEL macro.
Pls. advice.
To answer your questions:
1. Yes, the DSN is available in my system.
2. >>What you also could try is to set all the parts in the connection string bit by bit
Well, It was like that in the code. But, to make it look short here, I concatenated everything in one-line.
3. Yes, this is a code taken from my EXCEL macro.
Pls. advice.
Hi Shiva, forgot to ask yesterday what is the precise error message something with -20 etc...?
:O)Bruintje
:O)Bruintje
ASKER
EXCEL.exe
Exception: access violation(0xc0000005), Address:0x44a251d
This is all I get. Any idea ?
Exception: access violation(0xc0000005), Address:0x44a251d
This is all I get. Any idea ?
ASKER
I'd also like to mention that this does not happens in all the cases. Excel closes only when I try to open Read-only tables.
Or... lets have it this way. My back-end is sql server. I want to find the columns, their datatype, fieldlength(like sp_help) for a given table. If somebody could give me a solution without using any "sys" tables, I'd appreciate that. If you find that the answer for this question requires more points, kindly let me know.
Thanks.
Or... lets have it this way. My back-end is sql server. I want to find the columns, their datatype, fieldlength(like sp_help) for a given table. If somebody could give me a solution without using any "sys" tables, I'd appreciate that. If you find that the answer for this question requires more points, kindly let me know.
Thanks.
Hi Shivshankar, i've no idea
maybe asking for deletion of this question in customer support and asking this question again in VB would give you some more chance of solving it?
:O)Bruintje
maybe asking for deletion of this question in customer support and asking this question again in VB would give you some more chance of solving it?
:O)Bruintje
ASKER
bruintje, I do not get this problem when doing the same stuff in VB. It works!!.
It happens only in Excel or Word Macros :-(
It happens only in Excel or Word Macros :-(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
bruintje,
Sorry for the delay in response. It too did not work. I'm going to forget this problem. Anyway, thanks for all your efforts. I'd like to give you an "A" for that.
Thanks again.
Sorry for the delay in response. It too did not work. I'm going to forget this problem. Anyway, thanks for all your efforts. I'd like to give you an "A" for that.
Thanks again.
well thanks sorry to hear it didn't work, but i still wonder why it does work in VB but not in VBA
Maybe a simple question but is the DSN available on the machine you try this on?
What you also could try is to set all the parts in the connection string bit by bit instead of openening the connection with a complete string at once
btw is this code from Excel to SQL Server that's not completely clear from this description
:O)Bruintje