[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

How Challenging is it to Connect, Add, Update, Delete - VB and Oracle

Hello.

I've heard that Visual Basic has some interesting challenges when it comes to dealing with an Oracle database. Connecting to it is not terribly difficult. I was able to do that once.

But, adding records (recordsets) and updating and record deletion........

Is there somewhere where I can some sample code or, even better, a book dedicated to beginner/intermediate Visual Basic/Oracle database handling?
I've done this using PowerBuilder and Oracle. PowerBuilder's data window control with the data window object perform all of the connections and data retrieval very nicely. VB 6 requires coding.

JimNowlin
0
jnowlin
Asked:
jnowlin
  • 2
1 Solution
 
KtoshniCommented:
I have used Vb with Oracle and it's not that bad. I would suggest however that when you need to do updates, inserts or deletes that you use the ADODB command object. This will allow you to prepare normal Oracle SQL commands. Also, I prefer to avoid data aware controls as they cause more problems than they do solve them. It's better to make a number fo functions or routines which you can reuse in different projects. As far as books goes I suggest seeing what's avalable at Amazon.com - I've found plenty of good VB books there and you can trust the ratings they give. Hope this helps
0
 
PreeceCommented:
Give this a try:

Dim oAdoOracle As ADODB.Connection
Dim oRS As ADODB.Recordset
Dim sSQL as string

sSql = "select * from your_table where product_name = '" & sProdName & "'"
Set oRS = oAdoOracle.Execute(sSql)


sSql = "insert into your_table(product_id, product_sts, product_name, district ) & _
values(" & sProdID & "," & lProdStatus & ",'" & sProdName & "','" & sDistrict & "')"
oAdoOracle.Execute (sSql)


sSql = "update your_table set product_status = " & lProdStatus & " where product_id = " & lProdID
oAdoOracle.Execute (sSql)


sSql = "delete from your_table where product_name = '" & sProdName & "'"
oAdoOracle.Execute sSql


Hope this helps!
Preece
0
 
jnowlinAuthor Commented:
Preece,
I'm in the process of installing Personal Oracle 8i (again). I'll need some time to try your suggested code, as this install (into Windows2000 Pro this time) has always been difficult for me to do, the documentation's on the CD notwithstanding.

Ktoshni,
I took your advice and bought "Visual Basic Oracle 8 Programmer's Reference" by Dov Trietsch published by Wrox Press. It was a coin toss between a book by Snowdon and Trietsch. I have a number of books by Wrox and I consider them to be one of my best blocks of reference materials.

Jim
0
 
jnowlinAuthor Commented:
Hi Ktoshni,

I bought "Visual Basic Oracle 8" by Dov Trietsch on Wrox.
He also explains early on that the ADODC control should be used.

I will be posting more questions as I go through the book.

Thank You.

Jim
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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