?
Solved

VB Run-time error 91

Posted on 2004-10-19
8
Medium Priority
?
474 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 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 70

Expert Comment

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

840 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