Solved

VB6 with oracle

Posted on 2004-09-29
6
629 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
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 49

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 49

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now