Solved

VB Run-time error 91

Posted on 2004-10-19
8
450 Views
Last Modified: 2013-12-26
I am trying to open a connection to oracle database using following connection string:
cnstr = "Provider=ORAOLEDB.Oracle;Data Source=primedb;User ID=" & txtUserName.Text & ";Password=" & txtPassword.Text & ";"
at the following line:
cn.open cnstr
it gives "Run-time Error 91"
the connection variable is set in general section as "Dim cn as new adodb.connection"
but if i provide the user name and password as hard coded it works fine e.g.
cnstr = "Provider=ORAOLEDB.Oracle;Data Source=primedb;User ID=raajaindra;Password=mypassword;"
what could be the reason and the solution.
0
Comment
Question by:raajbaid
8 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 12354879
are you sure txtUserName.text and txtPassword.text contains the correct values?
0
 
LVL 13

Expert Comment

by:imarshad
ID: 12355692
>>are you sure txtUserName.text and txtPassword.text contains the correct values?
further adding to it...if it contains the correct value then try the following......

dim IntermediateString as string

IntermediateString= "Provider=ORAOLEDB.Oracle;Data Source=primedb;User ID=raajaindra;Password=mypassword;"
cnstr =IntermediateString

Imran
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 12355850
If you perform this, what is displayed ?

cnstr = "Provider=ORAOLEDB.Oracle;Data Source=primedb;User ID=" & txtUserName.Text & ";Password=" & txtPassword.Text & ";"
msgbox cnstr
0
 
LVL 2

Expert Comment

by:koolnurd
ID: 12355929
use this

cnstr = "Provider=ORAOLEDB.Oracle;Data Source=primedb;User ID='" & txtUserName.Text & "';Password='" & txtPassword.Text & "';"
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 12357126
Your cn object is not instantiated (no NEW have been used). How is cn is disclared? It should look like this:

dim cn as new adodb.connection

0
 
LVL 1

Author Comment

by:raajbaid
ID: 12357920
Thanks to you all nice guys. The problem was solved. Actually my mistake. I was giving wrong data source.
But now I'm struglling with another. I complied the application with P&DW and when I installed it on another computer, it refused to run with error "Run-time error 3706". Somewhere on net I was suggested to install MDAC and VB6SP5. I installed that too, but the problem persists.

Can anybody give some good solution to this problem.
0
 
LVL 33

Expert Comment

by:hongjun
ID: 12357947
>>The problem was solved
>> but the problem persists.

New problem, No problem, or same problem?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 12358592
you need to have MDAC_TYP.EXE in your package. Do you have it?
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now