Solved

how to add new data in vb using dao connection

Posted on 2001-07-08
6
245 Views
Last Modified: 2012-08-13
i want to know how to connect vb with oracle using dao connection and vb codes for adding data deleting modification etc please tell me the codes.
0
Comment
Question by:aliamirkhan
  • 4
6 Comments
 
LVL 7

Accepted Solution

by:
Inteqam earned 50 total points
Comment Utility
    ' DAO Example (Data Access Objects)  
      Dim wstemp As Workspace
      Dim dbtemp As Database
      Dim rstemp As Recordset
     
      Set wstemp = DBEngine.Workspaces(0)
      Set dbtemp = wstemp.OpenDatabase("", False, False, "ODBC;DSN=Oracle;USR=scott;PWD=tiger")
      Set rstemp = dbtemp.OpenRecordset(myquery.Text, dbOpenDynaset, dbSQLPassThrough)
     howmany = 0
      Combo1.Clear
      Do Until rstemp.EOF
           msgbox rstemp(0)
          rstemp.MoveNext
          howmany = howmany + 1
      Loop

     ' DAO Example (Data Access Objects)
      Dim contemp As New rdoConnection
      Dim rstemp As rdoResultset
      Dim envtemp As rdoEnvironment
      Set envtemp = rdoEngine.rdoEnvironments(0)
      envtemp.CursorDriver = rdUseServer
      ' or rdUseOdbc, rdUseNone, rdUseIfNeeded, rdUseClientBatch
      With contemp
        .Connect = "ODBC;DSN=Oracle;USR=scott;PWD=tiger"
         .EstablishConnection rdDriverNoPrompt, false, rdoForwardOnly
        ' or rdoStatic, rdoKeyset, rdoDynamic
       End With

     Set rstemp = contemp.OpenResultset("select ...") ' Your SQL here
End If

     howmany = 0
     With rstemp
     Do Until .EOF Or howmany > 2000
        msgbox .rdoColumns(0)
        ' Give a message box of the 1st column
        .MoveNext
        howmany = howmany + 1
        Loop
       
     ADO Example
     dim conn as ADODB.Connection
     dim rs as recordset
     Conn.Open "...", "...", "..."
     '           ^DSN   ^User  ^Password
     Set RS = Conn.Execute( "SELECT * FROM theTable" )
     do while not rs.eof
        msgbox RS(i).Value
        rs.movenext
     loop

Set RDODatabase = rdoEnvironments(0).OpenConnection("", rdDriverNoPrompt, True, "") Set RDOResultSet = RDODatabase.OpenResultset(SqlString.Text) TxtNumRows.Text = RDOResultSet.RowCount
0
 
LVL 7

Expert Comment

by:Inteqam
Comment Utility
0
 
LVL 1

Expert Comment

by:vim_asteya
Comment Utility
same as Integam,that should work
0
Free Trending Threat Insights Every Day

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.

 

Author Comment

by:aliamirkhan
Comment Utility
i have to run the program and see.But i think the code is correct
0
 
LVL 7

Expert Comment

by:Inteqam
Comment Utility
did it work, i didn't try it neither.

thanks anyway.
0
 
LVL 7

Expert Comment

by:Inteqam
Comment Utility
and welcome to Ex-Ex
:o)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

763 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

9 Experts available now in Live!

Get 1:1 Help Now