Neither update reacord nor displaying error

Last post 07-06-2005 1:55 AM by srinivasareddy. 6 replies.

Sort Posts:

  • Neither update reacord nor displaying error

    07-05-2005, 7:51 AM
    • Member
      492 point Member
    • srinivasareddy
    • Member since 05-12-2005, 5:09 AM
    • Singapore
    • Posts 101
    Hi,
     please find my code below, this one neither giving the error nor updating the record.


    Public Function UpdateQuoteData(ByVal ObjDs As DataSet, ByVal strTableName As String, ByVal intQuoteId As Integer)

    Dim ObjDa As OracleDataAdapter

    Dim strSQL As String

    Dim strReturnText As String = ""

    Dim objtmpDs As New DataSet

    Dim connection As New OracleConnection(connStr)

    Dim ObjCmd As OracleCommandBuilder

    Try

    strSQL = "SELECT * FROM " & strTableName & " WHERE QUOTE_ID = " & intQuoteId

    ObjDa = New OracleDataAdapter(strSQL, _connection)

    ObjDa.Fill(objtmpDs, strTableName)

    ObjCmd = New OracleCommandBuilder(ObjDa)

    ObjDa.InsertCommand = ObjCmd.GetUpdateCommand

    objtmpDs = ObjDs

    ObjDa.Update(objtmpDs, strTableName)

    Catch ex As OracleException

    strReturnText = ex.Message

    Throw ex

    Finally

    If strReturnText = "" Then

    strReturnText = "OK"

    End If

    End Try

    ObjDa.Dispose()

    Return strReturnText

    End Function

    can anyone help me where the problem hides

    Thanks & Regards,
    srini.
  • Re: Neither update reacord nor displaying error

    07-05-2005, 12:06 PM
    • Participant
      1,873 point Participant
    • dweezil
    • Member since 11-06-2002, 3:04 PM
    • San Francisco, CA USA
    • Posts 395
     srinivasareddy wrote:
    Hi,
     please find my code below, this one neither giving the error nor updating the record.


    Public Function UpdateQuoteData(ByVal ObjDs As DataSet, ByVal strTableName As String, ByVal intQuoteId As Integer)

    Dim ObjDa As OracleDataAdapter

    Dim strSQL As String

    Dim strReturnText As String = ""

    Dim objtmpDs As New DataSet

    Dim connection As New OracleConnection(connStr)

    Dim ObjCmd As OracleCommandBuilder

    Try

    strSQL = "SELECT * FROM " & strTableName & " WHERE QUOTE_ID = " & intQuoteId

    ObjDa = New OracleDataAdapter(strSQL, _connection)

    ObjDa.Fill(objtmpDs, strTableName)

    ObjCmd = New OracleCommandBuilder(ObjDa)

    ObjDa.InsertCommand = ObjCmd.GetUpdateCommand

    objtmpDs = ObjDs

    ObjDa.Update(objtmpDs, strTableName)

    Catch ex As OracleException

    strReturnText = ex.Message

    Throw ex

    Finally

    If strReturnText = "" Then

    strReturnText = "OK"

    End If

    End Try

    ObjDa.Dispose()

    Return strReturnText

    End Function

    can anyone help me where the problem hides



    Try changing your query to:

    strSQL = "SELECT * FROM '" & strTableName & "' WHERE QUOTE_ID = " & intQuoteId

    Strings and Dates in a query need to be enclosed in single-quotes.
    --dweezil

    SELECT * FROM users WHERE clue = 'yes';

    Records found: 0
  • Re: Neither update reacord nor displaying error

    07-05-2005, 8:52 PM
    • Member
      492 point Member
    • srinivasareddy
    • Member since 05-12-2005, 5:09 AM
    • Singapore
    • Posts 101
    SELECT * FROM 'users' WHERE clue = 'yes';    this is not  correct right..?  table name 'USERS' will not be like this. anyway thanks for help

     
    Thanks & Regards,
    srini.
  • Re: Neither update reacord nor displaying error

    07-05-2005, 9:42 PM
    • Participant
      755 point Participant
    • LuKiller
    • Member since 07-01-2005, 12:47 PM
    • San Nicolas - Argentina
    • Posts 158
    Have you checked if after the line "ObjDa.Fill(objtmpDs, strTableName)" the objtmpDs is filled? Try writing "objtmpDs = new DataSet()" before that line of code.

    LKZ:
    .\Arrobianos/.
    http://www.lukiller.net
  • Re: Neither update reacord nor displaying error

    07-05-2005, 9:45 PM
    • Participant
      1,873 point Participant
    • dweezil
    • Member since 11-06-2002, 3:04 PM
    • San Francisco, CA USA
    • Posts 395
     srinivasareddy wrote:
    SELECT * FROM 'users' WHERE clue = 'yes';    this is not  correct right..?  table name 'USERS' will not be like this. anyway thanks for help

     

    Frankly, I don't understand why you would pass a table name into an SQL query as a variable.
    If this is something you need to do then you should be using dynamic SQL, not static SQL. Dynamic SQL gives you flexibility of passing in different table and/or column names using bind variables.

    DECLARE
    l_var varchar2(50);
    my_column varchar2(25) := 'id';
    my_table varchar2(50) := 'users';
    sql = varchar2(500) := 'SELECT :my_column INTO l_var FROM :my_table WHERE clue='yes'';
    BEGIN
    execute mmediate sql;
    dbms_output.put_line(l_var);
    END;

    --dweezil

    SELECT * FROM users WHERE clue = 'yes';

    Records found: 0
  • Wink [;)] Re: Neither update reacord nor displaying error

    07-05-2005, 10:47 PM
    • All-Star
      26,551 point All-Star
    • Caddre
    • Member since 06-23-2003, 9:53 AM
    • Indy
    • Posts 5,308
     srinivasareddy wrote:
    SELECT * FROM 'users' WHERE clue = 'yes';    this is not  correct right..?  table name 'USERS' will not be like this. anyway thanks for help

     


    (SELECT * FROM 'users' WHERE clue = 'yes';) 
    I  am  sorry but the code above is dweezil signature, look again at the post and you will see the relevant code.  Hope this helps.
    Kind regards,
    Gift Peddie
  • Re: Neither update reacord nor displaying error

    07-06-2005, 1:55 AM
    • Member
      492 point Member
    • srinivasareddy
    • Member since 05-12-2005, 5:09 AM
    • Singapore
    • Posts 101

    i am not generating any sql query, it is genearting  string, string contains the sql query, i hope that doesn't matter, becoz i am able to write generic function like above in the post  for insertion.

    the problem hides over trasaction. i am using connection _connection, wich has transaction.  

    i am doing the following operations  in trasaction

    1. Transaction begin
    2. Deleting old stuff from the table
    3.Inserting Old and new Record to table by using above method.
    4. If all above sucess  sucess commit transaction

    deleting is working, but not  updating old recrods from fetched from database to dataset. it may be probably dataset behaviour.

    any help appriciated
     

    Thanks & Regards,
    srini.
Page 1 of 1 (7 items)