Question Updating dataset/datarow if data is populated from stored procedure

vbtush

New member
Joined
Mar 12, 2013
Messages
1
Programming Experience
1-3
Dear All,

I am using:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Microsoft Visual Studio 2010 : VB Express
Microsoft .NET Framework : Version 4.0.30319 RTMRel

When I populate dataset using select query and use OracleCommandBuilder and update dataadapter, data is saved in database.

But if I put same select in store procedure and use this to populate dataset then data is not updated in db.
I get this error
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
at

VB.NET:
da1.Update(ds1, [COLOR=red]"req"[/COLOR])

Please tell me where I am going wrong.

VB.NET:
Dim conn As New OracleConnection         
Dim da1 As OracleDataAdapter = New OracleDataAdapter        
 Dim ds1 = New DataSet           
With conn             
If .State = ConnectionState.Open Then .Close()              
 .ConnectionString = oraConnectString [COLOR=navy]' has conn info[/COLOR]            
 .Open()      
   End With          
 [COLOR=navy]' Define the command [/COLOR]       
  Dim cmd As New OracleCommand      
   cmd.Connection = conn          
 [COLOR=navy]' when I use sql query data is saved in db[/COLOR]     
    [COLOR=navy]' cmd.CommandType = CommandType.Text[/COLOR]      
   [COLOR=navy]' cmd.CommandText = "select * from request'[/COLOR][COLOR=red]"[/COLOR]        
  [COLOR=navy]' when I use stored proc data is NOT saved in db ?[/COLOR]       
  cmd.CommandType = CommandType.StoredProcedure      
   cmd.CommandText = [COLOR=red]"get_all_req_data"[/COLOR]          
 cmd.Parameters.Add(New OracleParameter([COLOR=red]"i_where_cond"[/COLOR], [COLOR=red]""[/COLOR])) [COLOR=navy]' passing blank where cond[/COLOR]         cmd.Parameters.Add(New OracleParameter([COLOR=red]"o_cursor"[/COLOR], OracleDbType.RefCursor, ParameterDirection.Output))             da1.SelectCommand = cmd          
       da1.Fill(ds1, [COLOR=red]"req"[/COLOR])        
   da1.MissingSchemaAction = MissingSchemaAction.AddWithKey         [COLOR=navy]' set PK[/COLOR]       
  Dim pk() As DataColumn = [COLOR=navy]{[/COLOR]ds1.Tables([COLOR=red]"req"[/COLOR]).Columns([COLOR=red]"request_no"[/COLOR])[COLOR=navy]}[/COLOR]       
  ds1.Tables(0).PrimaryKey = pk       
            Dim cb1 As OracleCommandBuilder = New OracleCommandBuilder(da1)     
     [COLOR=navy]' update found row for "position_profile" column[/COLOR]       
  Dim r As DataRow = ds1.Tables([COLOR=red]"req"[/COLOR]).Rows.Find([COLOR=red]"710_6"[/COLOR])    
     r([COLOR=red]"position_profile"[/COLOR]) = [COLOR=red]"14"[/COLOR]         
  da1.Update(ds1, [COLOR=red]"req"[/COLOR])
 
Back
Top