954,558 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

let me know d steps to connect to oracle(sql) from vb6

hi
i am Raghavendra. I dont know anything abt how to connect to oracle (sql) from VB 6 . could u plz let me know d steps n d code for executing the queries. its very urgent plz let me know

gurutheja
Newbie Poster
3 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

Hi Raghu,

Add References
Microsoft ActiveX Data Object Library 2.0 to ur project

Connection To Oracle is :

Dim adoCn As New ADODB.Connection
Dim sSQL as String
Dim RST As New AdoDb.RecordSet
 
sSQL= "Provider=MSDAORA.1;Password=MyPwd;" _
        & " User ID=MyUserName;Data Source=MyDataSource;" _
        & " Persist Security Info=True"
    With adoCn
        .CursorLocation = adUseClient
        .ConnectionString = DBStrCnct
        .ConnectionTimeout = 30
        .Open
    End With

To Open A Record Set Use This Statement :
    
    sSQL = "Select * From MyTable"
    Set RST = Nothing
    RST.Open sSQl, adoCn, adOpenDynamic, adLockOptimistic
    '
    If Not (RST.EOF And RST.BOF) Then
        'Records Present Do ur Coding here
    Else
        'Records Not present
    End If

To Execute the SQWL Statement :

sSQL="Update MyTable Set MyField = '" & Text1.Text & "' Where MyPK = 20"
adoCn.Execute sSQL

I hope it is clear.
If u have any problems, let me know

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

hi veena,
Thank u very much, but i am not getting to know how to select or add oledb or activex and all those intial procedures before doing the coding. If u could plz help me as i know nothin about vb, i have an interview and they asked me for the database connectivity.
Regards
Raghu

gurutheja
Newbie Poster
3 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

Hi,

No Need To add any Active x or oledb control.

Just add the References in Project Menu.
Microsoft ActiveX Data Object Library 2.0

Place Text1, Text2 TextBoxes on the Form.
Change DatabaseName, UserID and Password according to ur connections.
In Form Level After the Option Explicit type this

Dim adoCn As New ADODB.Connection
Dim sSQL as String
Dim RST As New AdoDb.RecordSet

In Form Load

Private Sub Form_Load()
sSQL= "Provider=MSDAORA.1;Password=MyPwd;" _
& " User ID=MyUserName;Data Source=MyDataSource;" _
& " Persist Security Info=True"
With adoCn
.CursorLocation = adUseClient
.ConnectionString = DBStrCnct
.ConnectionTimeout = 30
.Open
End With

'
sSQL = "Select * From MyTable"
Set RST = Nothing
RST.Open sSQl, adoCn, adOpenDynamic, adLockOptimistic
'
If Not (RST.EOF And RST.BOF) Then
RST.MoveFirst
Text1.Text = RST(0)
Text2.Text = RST(1)
End If
RST.Close
Set RST= Nothing

End Sub


Thats ALL.


Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

Hi,
thank you very much veena if any further query i wil get back to you.

Regards
Raghu

gurutheja
Newbie Poster
3 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

plz dear help me out am also struck with same prob..
am new to VB so write it in detail for me plz..
help me out

afreaz
Newbie Poster
1 post since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

How about starting a new thread, and not responding to one that is like, 3 years old?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

create a odbc for the database , table you would like to connect to, then invoke vb select either standard / data project , go to add in visual data manager , and build a form using the odbc , in the data control connect(property) you will get connection string if you would like to use it further for queries...
Regards
Dev

jikraant
Newbie Poster
1 post since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

i get this messege
ora-12154: tns:could not resolve service name
Azizul

azizulkhn
Newbie Poster
1 post since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You