Solved

Inserting data into Oracle Database from VB

Posted on 2001-06-07
7
130 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

706 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

17 Experts available now in Live!

Get 1:1 Help Now