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

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

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

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

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

Regards
Raghu

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

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.