Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle ASP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle ASP Using ASP with Oracle databases. For Oracle discussions not specific to ASP, please see the Oracle forum. For more ASP discussions, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle ASP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 25th, 2009, 05:58 PM
Registered User
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem updating table

Hello,

I have an Oracle DB with some table's, I can insert data to the table's, but when I want to update the table's there is nothing happend.

I use the query below written in Delphi.Prism. What is wrong with this query?
Code:
   try
    OracleConn := new OracleConnection;
    OracleConn.Connectionstring := 'User Id=SCHULDHULP;Password=pass; Data Source=Omgeving;';
    OracleConn.Open;
    myOracleTransaction := OracleConn.BeginTransaction();
    cmd := new OracleCommand;
    cmd := OracleConn.CreateCommand;
     if RadioButton2.Checked = true then SEXE := 'Man'else
        SEXE := 'Vrouw';
     if RadioButton5.Checked = true then VER := 'Ja' else
        VER := 'Nee';
     if RadioButton3.Checked = true then GEH := 'Ja' else
        GEH := 'Nee';
     if RadioButton7.Checked = true then MOB := 'Abonnement' else
         MOB := 'Prepaid';
    TextBox154.Text := BSNTxt.Text;
    cmd.Connection := OracleConn;  
        cmd.CommandText := "Update AANVRAGER SET GESLACHT='"+SEXE+"',GEHEIM='"+GEH+"',ABONNEMENT='"+MOB+"',GAAT_VERHUIZEN='"+VER+"'WHERE ALGEMEEN.BSN = 9675463772";
        cmd.ExecuteNonQuery();
        OracleConn.BeginTransaction.Commit;
    finally
        OracleConn.Close();
        OracleConn.Dispose();
    end;
Reply With Quote
  #2 (permalink)  
Old April 25th, 2009, 08:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

Have you tried printing out the contents of
Code:
cmd.CommandText
after you populate it to see what is in there ? Then if it looks ok try running that SQL in SQL Plus, or a similar DB tool, to ensure that it is valid, if you are not seeing the update then your SQL could be suspect, if the update works directly on the database then you will need to take another look at your code.
__________________
All the best

Greg
------------------
Greg Griffiths
Web & Livelink Developer
http://www.greggriffiths.org
Reply With Quote
  #3 (permalink)  
Old April 26th, 2009, 03:44 AM
Registered User
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question

Thanks for the reply.

If I use this:

Code:
cmd.CommandText := "Update AANVRAGER SET GESLACHT='test' WHERE ALGEMEEN.BSN = 9675463772";


The query is not updating the table from code.

If I do the same query from querybuilder within Visual Studio 2008 then the table is updated.

There must be something wrong in the code.
Reply With Quote
  #4 (permalink)  
Old April 26th, 2009, 05:10 AM
Registered User
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

Thanks Greg,

It seems that for some other reason the cmd.CommandText produces an empty string. I have recoded it and now the update is perfectly done.

Code:
   try
    OracleConn := new OracleConnection;
    cmd := new OracleCommand;
    OracleConn.Connectionstring := 'User Id=SCHULDHULP;Password=pass; Data Source=Omgeving;'; 
    OracleConn.Open;
    cmd.Connection := OracleConn;
         cmd.CommandText := "UPDATE AANVRAGER SET GESLACHT = 'Vrouw' WHERE BSN = 9675463772";
         cmd.ExecuteNonQuery();
    end;
    finally
        OracleConn.Close();
        OracleConn.Dispose();
    end;
Reply With Quote
  #5 (permalink)  
Old June 28th, 2009, 02:56 AM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

Willemt:

Just by "eyeballing" your update statement, I have a couple of suggestions:
  1. Oracle recognizes "||" for concatenation;
  2. Did not see the "FROM" keyword in UPDATE statement;
  3. Not knowing your Scheme Definition for field BSN, if BSN is character, it needs to be enclosed in single-quotes '12345'.
Remember to write your SELECT statement for ORACLE using Delphi, not the other way around. Just a suggestion.

Hope this helps.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.

Last edited by peace95; June 28th, 2009 at 03:02 AM.
Reply With Quote
  #6 (permalink)  
Old June 24th, 2015, 04:34 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

GOOD QUESTION ASKED BY YOU
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating one table with data from another table dirtdog22 Access VBA 1 January 21st, 2008 03:41 PM
problem with Updating a table hertendreef SQL Server 2005 1 August 4th, 2007 02:47 AM
Updating table every now and then rtr1900 Classic ASP Databases 2 December 2nd, 2005 02:12 AM
ch 6 commit.php problem updating movie table statusquo BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 May 2nd, 2005 10:02 PM
updating table markhardiman Classic ASP Databases 2 September 29th, 2004 12:35 PM



All times are GMT -4. The time now is 12:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.