New topic: 

Prepared Statement - Update - ODBC - data not applied

<http://forums.realsoftware.com/viewtopic.php?t=47958>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        superjacent          Post subject: Prepared Statement - Update - 
ODBC - data not appliedPosted: Thu May 23, 2013 7:36 am                         
        
Joined: Sat Oct 01, 2005 4:47 am
Posts: 120
Location: Melbourne, Australia                Hope someone can help. I'm 
converting my traditional SQL statements to Prepared statements. I'm using ODBC 
connected to a Microsoft Access database. I've successfully got the SQL SELECT 
prepared statement working. I'm having issues with the UPDATE prepared 
statement. I am not receiving any db errors but the data is not being applied. 
I navigate away from the record, return to it and the old data is there, no 
changes. Below is the method I use in creating the UPDATE prepared statement. 

Function BindParametersUpdate(pStr_SQL_PreparedUpdate as string) As Boolean
  Dim ps As ODBCPreparedStatement
  Dim i as integer
  dim var_Value as Variant
  ps = ODBCPreparedStatement(db.Prepare(pStr_SQL_PreparedUpdate))
  
  ' First, cycle SaveFields array (data entered by user) for binding.
  
  for i = 0 to UBound(c_arv_SQL_SaveFields)
  var_Value = c_arv_SQL_SaveFields(i,2)   // actual data value
  
  Select Case c_arv_SQL_SaveFields(i,1) // this is the data type
  
  case k_TYPE_TEXT
  ps.BindType(i,ODBCPreparedStatement.ODBC_TYPE_STRING)
  case k_TYPE_NUMBER
  ps.BindType(i,ODBCPreparedStatement.ODBC_TYPE_INTEGER)
  case k_TYPE_DATE
  ps.BindType(i,ODBCPreparedStatement.ODBC_TYPE_DATE)
  
  // further case statements maybe required
  end select
  
  ps.Bind(i,var_Value)
  
  next i
  
  ' now work on key field parameter, the actual record to be updated.
  
  ps.BindType(i,ODBCPreparedStatement.ODBC_TYPE_INTEGER)
  ps.Bind(i,c_ari_RecKeyFields(c_int_RecPosition))      // Unique key - data 
value
  
  ps.SQLExecute
  
  if db.Error then
  MsgBox "Binding Error " + db.ErrorMessage
  return false
  else
  return true
  end if
  
End Function


For debugging purposes, I've confirmed that the data values match up precisely 
with the parameters (?) in the prepared statement string (that is passed into 
the method).  

Am I missing something? Any advice or suggestions are most welcome.      
_________________
Steve
rs2012 r2.1 Windows 7.  
                             Top                pfargo          Post subject: 
Re: Prepared Statement - Update - ODBC - data not appliedPosted: Thu May 23, 
2013 8:00 am                         
Joined: Mon Oct 13, 2008 4:26 am
Posts: 58                Are you committing the update?   
                             Top                superjacent          Post 
subject: Re: Prepared Statement - Update - ODBC - data not appliedPosted: Thu 
May 23, 2013 8:12 am                                 
Joined: Sat Oct 01, 2005 4:47 am
Posts: 120
Location: Melbourne, Australia                pfargo wrote:Are you committing 
the update?
No, I wasn't. Inserting a db.commit just after the ps.SQLExecute does not alter 
things, data is still not saved.      
_________________
Steve
rs2012 r2.1 Windows 7.  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to