Solved

VB6 with oracle

Posted on 2004-09-29
6
685 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 52

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
MS Dynamics Made Instantly Simpler

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

 
LVL 52

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…

705 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