OracelHelper class again!!

Posted on 2004-11-29
Medium Priority
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
  • 4
  • 2
LVL 10

Assisted Solution

123654789987 earned 150 total points
ID: 12694762
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

ID: 12694893
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

ID: 12694971
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12695174
i want to use the qurey "select * from mytable " with a WHERE clause
which method should i use

Accepted Solution

mani_sai earned 150 total points
ID: 12696394
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

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

Expert Comment

ID: 12727120
Sorry for the delay in replying.

Sure, you can do it the same way.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

862 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