PDA

View Full Version : Excel weird behavior when connecting through ADODB



raj85
08-27-2013, 08:36 AM
Hi Mates,

I am connecting to Sybase DB using ADODB object and DSN and I have given dropdown to user to select environment to connect (PROD/QA). Sometimes It works for QA perfectly and not for PROD and vice versa.
I am executing a SP to check database access level of user
"sp_helpuser 'test' and pulls record in a recordset.
In case of one environment it works perfectly and pull data and for other it not pulling anything.

I really surprise how this can be possible.
:banghead:
Please help me with this
: pray2:


ConnStr = CStr("DSN=" & DSN & ";Uid=" & .[G2] & ";Pwd=" & .Pass_Text)
End With
CnSrc1.Open ConnStr
Sql = "exec sp_helpuser '" & UID & "'"
Rs1.Open Sql, CnSrc1

Jan Karel Pieterse
08-27-2013, 10:42 PM
Are you sure both users enter the right credentials?

raj85
08-28-2013, 12:15 AM
Thank you Jan fir your reply.Yes I am testing this tool and I have not yet distributed to the users.I am entering correct credentials.I am able to log in from RapidSQL

Jan Karel Pieterse
08-28-2013, 02:42 AM
And the user is available in the table the SP is pulling data from?

What if you (temporarily) change this line:
Sql = "exec sp_helpuser '" & UID & "'"
to a fixed SQL string with the username that does work?

raj85
08-30-2013, 06:40 AM
Hi Jan,

Thank you for the response.

Yes, User is available in the table the SP is pulling from.
And I also tried using fixed string "exec sp_helpuser 'rock'" but no luck.

its so strange it happen for only to query which checks user's database access.
I also tried replacing below query from ADODB but waste.
select * from sysusers where name = 'jhonK'