Solved

VB6 with oracle

Posted on 2004-09-29
6
671 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 25 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 51

Assisted Solution

by:Ryan Chong
Ryan Chong earned 25 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 75 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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.
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…
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…

733 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