Solved

Inserting data into Oracle Database from VB

Posted on 2001-06-07
7
136 Views
Last Modified: 2010-05-02
How can I insert, update, delete data in a Oracle Database using Visual Basic.  I connected my application to the Oracle database with OLE DB provider for Oracle. For exemple : I have some data and I want to insert it into the Oracle's Database

I have tried this...

rsOracle.addnew
rsOracle.Fields("IdPatient") = IdPatient
rsOracle.update

but it didn't worked

I think I have to pass by an oracle procedure....but I'm not sure.

Help me
0
Comment
Question by:Peewee20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:thuannc
ID: 6166060
Your code is true way to update any db with adodb. What kind of error or what happend after your update?. It is may be your connection string is incorrect or some oracle's constraints is unsatisfied
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6166305
can u put ur connection, recordset declarations here?

did u check the cursor type and locking type for recordset?

if u try an insert statement to execute with connection object, does it work?

if not try the same statement in oracle and check if you get any errors.

hope it helps.


0
 

Expert Comment

by:agl
ID: 6166866
Peewee20

Have you tried using connection.execute(sql statement).
if that does not work post the code you have written or the error that's getting raised
0
Industry Leaders: 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!

 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6166880
agl,

u have posted a similar comment, as i have posted.

hope u had not noticed it.
0
 

Author Comment

by:Peewee20
ID: 6168246
I can insert data into my Oracle's Database if I put an "Insert Into" Statement into the .source of my recordset
ex:

strSQL = "Insert into tblPatient(IdPatient) values ('H1')"
rsOracle.source = strSQL
rsOracle.open

rsOracle.close

After that I can see H1 in my Oracle DataBase.  
It work but I'm sure it's not the best way to do it....

I don't know why I can't use .AddNew ?? As shown in my question!!!
0
 
LVL 9

Accepted Solution

by:
Valliappan AN earned 75 total points
ID: 6168285
Peewee20,

Actually SQL Statements are faster than using vb recordsets, so it is alright that you use INSERT statements, may be like this:

strSQL = "Insert into tblPatient(IdPatient) values ('" & txtIdPatient & "')"
Conn1.Execute strSQL

where, txtIdPatient contains the value for the Patient Id and Conn1 is the ADODB connection.
0
 

Author Comment

by:Peewee20
ID: 6168942
Thank you very much?  I had a word with my teacher and I told me the same thing as you :)

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

734 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