Solved

VB Run-time error 91

Posted on 2004-10-19
8
458 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

820 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