Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Inserting data into Oracle Database from VB

Posted on 2001-06-07
7
Medium Priority
?
142 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
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
Independent Software Vendors: 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 300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

916 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