Solved

Inserting data into Oracle Database from VB

Posted on 2001-06-07
7
137 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

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!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month4 days, 5 hours left to enroll

630 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