?
Solved

VB6 with oracle

Posted on 2004-09-29
6
Medium Priority
?
695 Views
Last Modified: 2010-05-18
Dear Sir

  please provide me with the simplest way to connect my vb6 form to oracle DB, table for insert, edit, delete   if there is any lib or wizard it will be better


Thank you

Eng. Omar Fayyad
0
Comment
Question by:omarmf
[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
6 Comments
 
LVL 18

Accepted Solution

by:
JR2003 earned 75 total points
ID: 12185440
omarmf,

I think the key thing is to be able to connect to the database. Once you have done this you can then use styandard SQL.


'In a module put the following line:
Public myDB As ADODB.Connection

'In a function to connect to the database:
    Set myDB = New ADODB.Connection
    With myDB
        .ConnectionString = "UID=scott;PWD=tiger;DRIVER={Microsoft ODBC for Oracle};SERVER=myTNSName;"
        .Open
    End With


'In a function to update a table on the database:

Dim MySet as ADODB.Recordset
Set MySet = New ADODB.Recordset
myDB.Execute "Update Table1 Set field1 = 'A' where field2 = #XYZ'" , , adExecuteNoRecords
0
 
LVL 53

Assisted Solution

by:Ryan Chong
Ryan Chong earned 75 total points
ID: 12186654
I used to put a provider there, not sure if omit the provider will it still work?


...
.ConnectionString = "Provider=MSDASQL;DRIVER={Microsoft ODBC for ORACLE};UID=scott;PWD=tiger;Server=myTNSName"
...



Other methods using of ConnectionString for Oracle can be found at links below:

http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForOracleFromOracle
http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForOracleFromMicrosoft
http://www.connectionstrings.com

regards
0
 
LVL 3

Assisted Solution

by:sgayatri
sgayatri earned 225 total points
ID: 12188270
ryancys,
its allowed without giving provider, that is the advantage of using this ...
 
omar,
try this.
Add a command button to your code
Add Project >> references >> Activex Data Objects 2.0 library
Add Project >> references >> Activex Data Objects Recordset 2.1 library

private sub command1_click()

dim cn as new adodb.connection
dim rs as new adodb.recordset

on error goto conerr
with cn
''' substitute proper parameters for username,password,Server
.ConnectionString = "DRIVER={Microsoft ODBC for ORACLE};UID=username;PWD=password;Server=myTNSName"
.open
end with

on error goto rserr
str="select a,b from db"   '' add your select/insert/update  statement here
rs.open str1,cn,adopenkeyset
''''your data is in recordset now if it is a select statement
'''You can use it as
field1 = rs(0)
field2 = rs(1)

exit sub
conerr:
  msgbox "connection error here!"
  msgbox err.description,,err.number
  exit sub

rserr:
  msgbox "Recordset error here!"
  msgbox err.description,,err.number
 
end sub
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12188301
Thks for the info, sgayatri!
0
 

Author Comment

by:omarmf
ID: 12201244
Dear sir

I m finding toubles in logning to the oracle server

.ConnectionString = "DRIVER={Microsoft ODBC for ORACLE};UID=SCOTT;PWD=TIGER;Server=MYNDBNAM"


What to do ???
0
 

Author Comment

by:omarmf
ID: 12201357
i think the problem could be solved by adding script describing connect as sysdba
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

765 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