Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 145
  • Last Modified:

Inserting data into Oracle Database from VB

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
Peewee20
Asked:
Peewee20
1 Solution
 
thuanncCommented:
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
 
Valliappan ANSenior Tech ConsultantCommented:
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
 
aglCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Valliappan ANSenior Tech ConsultantCommented:
agl,

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

hope u had not noticed it.
0
 
Peewee20Author Commented:
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
 
Valliappan ANSenior Tech ConsultantCommented:
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
 
Peewee20Author Commented:
Thank you very much?  I had a word with my teacher and I told me the same thing as you :)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now