OracelHelper class again!!

Posted on 2004-11-29
Last Modified: 2008-01-16
I need to insert records into a table from a form where can input my values.
I have to use the Microsoft Data Access Application Block , OracleHelper class only!!
I am having a nightmare from the time i was introduced to this DAAB, there are lots
of methods like ExecuteDataset,ExecuteReader,ExecuteScalar,ExecuteNonQuery

which one should i use
I did a lot of searching but the parameters which these methods are stored procedures
but i dont have any storeprocs.
i just have to do one small insertion
can anyone help me out??

Question by:vishnunarayan
    LVL 10

    Assisted Solution

    For a simple insertion in the database u have to use the ExecuteNonQuery method with the following signature

    public shared ExecuteNonQuery(connection as OracleConnection, commandText as string ) as Int

    or u can use
    public shared ExecuteNonQuery(connection as OracleConnection, CommandYype.Text,commandText as string ) as Int

    u don't have to worry about any other parameters or overloads

    Author Comment

    Can i use something like

    OracleHelper.ExecuteNonquery(sConnectionString as OracleConnection, CommandType.Text, commandText as string)
    commandText = "insert into mytablename values(' ', ' ')"  ?????

    I actually want to give my qurey as "select * from mytable"
    and say recordset.addnew so that i can check for duplication in my table.

    Author Comment

    ok now i get it
    ExecuteNonquery will return an integer value
    i used it this way
    Dim rtnvalue as integer

    rtnvalue = OracleHelper.ExecuteNonQuery(sConnectionString, CommandType.Text, "INSERT INTO OraTest values (" & txtcatno.Text & "," & txtsiteid.Text & "," & txtCategory.Text & "," & txtEmail.Text & ")")

    But this doubt of mine remains still

    I actually want to give my qurey as "select * from mytable"
    and say recordset.addnew so that i can check for duplication in my table

    Author Comment

    i want to use the qurey "select * from mytable " with a WHERE clause
    which method should i use
    LVL 8

    Accepted Solution

    First Step :
    You can use ExecuteReader for the select query.

    Second Step:
    Check to see If it returns nothing then you can use ExecuteNonQuery for Insert.



    Author Comment

    If i want to do the same in ASP.Net i think i can use the methods in the same way isnt't??
    LVL 8

    Expert Comment

    Sorry for the delay in replying.

    Sure, you can do it the same way.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    745 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

    19 Experts available now in Live!

    Get 1:1 Help Now