Solved

VB Run-time error 91

Posted on 2004-10-19
8
464 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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.
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…
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…

738 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