Results 1 to 9 of 9

Thread: Changing a record in an Oracle database

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    4

    Changing a record in an Oracle database

    How would I go about changing a record in a oracle database, using Ado and a MSHFlexGrid.
    Thank you!!!

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Does the UPDATE DDL work in your case? BTW, is your Oracle running in Window OS?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    How are you editing the boxes in the flexgrid? Are you editing directly, or are you using a 'transparent' textbox?

    Either way, in their respective validation events, you can use this code:

    VB Code:
    1. Private Sub txtflex_KeyPress(KeyAscii As Integer)
    2.  
    3.  
    4.   If KeyAscii = 13 Then
    5.   'ENTER
    6.    
    7. sqlsomething = "UPDATE tablename SET " & objrsflx.Fields(flex.Col).Name & " = '" & Replace(txtflex.Text, "'", "''") & "' WHERE " & "(SOME CONDITION HERE, SUCH AS PRIMARY KEY);"
    8.  
    9. objconn.BeginTrans
    10. objconn.Execute sqlsomething
    11. objconn.CommitTrans
    12. objrsflx.Update
    13.  
    14. call FunctionToFillFlexGridAgain()
    15.  
    16. txtflex.Visible = False
    17.  
    18. ElseIf KeyAscii = 27 Then
    19.  
    20. txtflex.Visible = False
    21. End If
    22.  
    23.  
    24. End Sub

    Note: objrsflx is the recordset I used to fill in the flexgrid, and sqlsomething is the statement to be executed to update the oracle database, and I have used a textbox txtFlex to edit values.

    modify as appropriate.
    HTH

  4. #4
    New Member
    Join Date
    Jan 2003
    Posts
    8
    Is 13 the data in the recordset?
    I tried the code, put in my tablename, nothing happened?
    I will be changing the data using a command button.

    I want to be able to change a string value, to a string value

    sqlsomething = "UPDATE tablename SET " & objrsflx.Fields(flex.Col).Name & " = '" & Replace(txtflex.Text, "'", "''") & "' WHERE " & "(SOME CONDITION HERE, SUCH AS PRIMARY KEY);"

    objrsflx.Fields(flex.Col).Name & " = '" // should I put something where the = is?

    txtflex.Text, "'", "''") //or do I put the text in here?

    Thanks.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by RachWill
    Is 13 the data in the recordset?
    I tried the code, put in my tablename, nothing happened?
    I will be changing the data using a command button.

    I want to be able to change a string value, to a string value

    sqlsomething = "UPDATE tablename SET " & objrsflx.Fields(flex.Col).Name & " = '" & Replace(txtflex.Text, "'", "''") & "' WHERE " & "(SOME CONDITION HERE, SUCH AS PRIMARY KEY);"

    objrsflx.Fields(flex.Col).Name & " = '" // should I put something where the = is?

    txtflex.Text, "'", "''") //or do I put the text in here?

    Thanks.
    Are you jessejames???

    You put the text in txtflex, the transparent, borderless textbox.
    keyascii= 13 is for when the user presses enter. if the user presses Enter (key 13), then the code to update the database will execute.

    Code:
    sqlsomething = "UPDATE tablename SET " & objrsflx.Fields(flex.Col).Name & " = '" & Replace(txtflex.Text, "'", "''") & "' WHERE " & "(SOME CONDITION HERE, SUCH AS PRIMARY KEY);"
    can evaluate to

    sqlsomething = "UPDATE tablename SET membername = 'geordie' WHERE memberid = 92;"

    "membername" is the name of the column in which you are currently editing.
    "geordie" is the value in the textbox.
    "memberid" is the primary key of the table, "92" is the value for that current row you are editing.

    HTH

  6. #6
    Member
    Join Date
    Jan 2002
    Location
    Cornwall
    Posts
    38

    Won't work in oracle database

    Mendhak,
    Have you tried the update function on a oracle database?
    I tried using your code in oracle and it will not work.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Won't work in oracle database

    Originally posted by Pajess
    Mendhak,
    Have you tried the update function on a oracle database?
    I tried using your code in oracle and it will not work.
    Do you have three screennames?!?

    Post the code that you tried. The code I posted is incomplete, it was to give you an idea.

    What code did you use, and what error did you get?

  8. #8
    Member
    Join Date
    Jan 2002
    Location
    Cornwall
    Posts
    38
    What are you going on about three screennames???? There are probably quite a few people wanting to know about oracle.
    I just know to "talk" to a oracle database you need commands oracle understands, i'm not sure if oracle would understand update.
    That is why I asked have you tested it on a oracle database to see if update does work.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Posts
    4
    Update didn't work for me.
    Mendhak - I have no clue who rachwill is, or pajess, nor do I want to.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width