locked
Pushing and Pulling Data From Oracle Database To/From A VB App RRS feed

  • Question

  • Hello. I'm newer to Visual Basic and to databases. What I want to do is create a Visual Basic app that I can run on my computer and have it push the data to an Oracle 11g database on my server(Microsoft Server 2008). I was able to successfully create the Connection String to my Oracle database. The connection works fine in the app as I can connect and disconnect no problem. I'm having 2 issues now:

    1. Pulling a single value from the database in a particular column
    2. Pushing data entered in the app to particular columns in the Oracle database

    I have my App basically built cosmetically and have most of the code done except for this pulling and pushing from the database.

    First, I want to use the btnRetrieve button to retrieve the following SQL syntax:

    "SELECT MAX(TRANS_NUM) FROM BRIAN.FINANCES"

    This will give me the latest transaction number but in VARCHAR2 datatype. Somehow I need to cast it to an Integer and bring it into my app into the txtTransNum textbox. I then want to add 1 to it so that way I won't have to manually find the last transaction number in that column in the database and manually enter it. In theory, I should be able to pull the last Transaction Number from the database, change it to an Integer, add 1 to it, and put this value in the txtTransNum textbox. Is that possible? I'm sure it is, I just don't know how to get to that point.

    Once this is done, there should now be 2 fields already filled in: txtTransNum with the previous query and txtTransEnteredDate with today's date in Oracle format of 'DD-MMM-YYYY'.

    This is where the second hurdle begins: pushing the app data to the database. Once I have all items filled in on the app, I want to then push that data to the correct columns in the database. You can see in my code for the app that I've attempted this, but cant seem to get it right. I thinking I'm missing pieces to the code. See the code snippet below:

    [CODE] Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

            cmd.CommandText = "INSERT INTO BRIAN.FINANCES (TRANS_NUM, TRANS_DESC, TRANS_CATEGORY, INCOME, TRANS_AMOUNT, TRANS_DATE, TRANS_ENTERED_DATE) values (txtTransNum.text, txtTransDesc.text, txtTransCategory.text, txtIncome.text, txtTransAmount.text, txtTransDate.text, txtTransEnteredDate.text)"

        End Sub[/CODE]


    What am I missing here? The database connection will already be open when I click the Open button. I should then be able to retrieve the data I want(1) and then push all the data in the text boxes to the database(2). I should  then close the database connection and exit the program. Any help on coding this to happen would be great. Thank you in advance.

    • Moved by Amanda Zhu Tuesday, July 23, 2013 8:54 AM
    Friday, July 19, 2013 2:51 PM

Answers

All replies

  • Hello,

    Thank you for your post.

    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System and Visual Studio Editor.

    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.

    Best regards,


    Amanda Zhu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 23, 2013 8:54 AM
  • I'd ask in the Visual Basic forum.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    Tuesday, July 23, 2013 9:15 PM