+ Reply to Thread
Results 1 to 11 of 11

vba macro to insert into oracle tables

  1. #1
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    vba macro to insert into oracle tables

    Hi

    I have a work sheet I want the user to click the button and insert the data excel sheet into oracle table

    how to do this please ?

    Thanks

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: vba macro to insert into oracle tables

    Use ADO for any CRUD activity.

    http://www.w3schools.com/asp/ado_intro.asp
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: vba macro to insert into oracle tables

    Can you provide me with an example PLS ?

  4. #4
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: vba macro to insert into oracle tables

    I write this code but it gave me an error
    PLS advise
    find attached file


    Sub uploadListOfItems()
    'Oracle connection variables
    Dim dbUserName As String
    Dim dbPassword As String
    dbUserName = "ORACLE_USERNAME"
    dbPassword = "ORACLE_PASSWORD"

    Dim dbDSN As String
    dbDSN = "MY_TNS_ALIAS"

    'Create and Set Session / Create Dynaset = Column Names
    Dim OraSession As Object
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")

    Dim OraDatabase As Object
    Set OraDatabase = OraSession.OpenDatabase("test101", "apps" / "apps")

    Dim Oradynaset As Object
    Set Oradynaset = OraDatabase.DBCreateDynaset("SELECT * FROM MY_ORACLE_TABLE", 0&)

    'Upload data variables
    Dim site As String
    Dim item As String

    'Initialize upload
    ActiveSheet.Activate
    Range("A2").Select
    order_id = 1

    'Iterate through each cell and upload to MY_ORACLE_TABLE
    Do Until Selection.Value = ""
    site = ActiveCell.Value
    item = ActiveCell.Offset(0, 1).Value

    'Add new record
    Oradynaset.AddNew
    Oradynaset.Fields("USERNAME").Value = Application.UserName
    Oradynaset.Fields("SITE").Value = site
    Oradynaset.Fields("ITEM").Value = item
    Oradynaset.Update

    Selection.Offset(1, 0).Select

    order_id = order_id + 1
    Loop
    End Sub
    Attached Images Attached Images

  5. #5
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: vba macro to insert into oracle tables

    Try this .

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: vba macro to insert into oracle tables

    # Thanks a lot
    Last edited by Khaled Diab; 11-25-2014 at 09:13 AM.

  7. #7
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: vba macro to insert into oracle tables

    you are welcome, please enclose the code in your earlier post using #.

  8. #8
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: vba macro to insert into oracle tables

    Done !

  9. #9
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: vba macro to insert into oracle tables

    I meant post #4 and the entire code that you posted without the code block tag #.

    Select the entire code in your post #4 and then click on the # icon.

  10. #10
    Registered User
    Join Date
    06-09-2014
    Posts
    31

    Re: vba macro to insert into oracle tables

    Excuse me but i dont know what you are talking about

  11. #11
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: vba macro to insert into oracle tables

    You post #4 should look like this :


    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Fetch data from Oracle to Excel with Oracle ODBC driver using VBA
    By clam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2022, 11:39 AM
  2. Excel to Oracle connection using VBA for various oracle versions
    By pam79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2012, 02:39 AM
  3. Replies: 0
    Last Post: 04-24-2006, 07:20 PM
  4. [SOLVED] Connect to Oracle using Microsoft ODBC for Oracle
    By Kent in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2006, 11:55 PM
  5. [SOLVED] ODBC data insert to Oracle
    By renee in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 10-18-2005, 04:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1