New topic: 

MySQL db w/recordset not working 2010 r4.1

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

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        carlfitzsimmons          Post subject: MySQL db w/recordset not 
working 2010 r4.1Posted: Thu Nov 18, 2010 7:13 pm                         
Joined: Tue Sep 19, 2006 5:10 pm
Posts: 113                I have an application that has a mysql db and a 
window I place all fields in. 

I start out like this
  Dim rs as RecordSet
  Dim db as mySQLCommunityServer
  Dim d as new Edit_DB_item_Dialog
  
I use rs = db.SQLSelect(sql) to get the info from the db table which always 
include the id and is defined in the table as a Primary Key.
I fill the members of the window by this  d.Device_Type = 
rs.Field("Device_Type").StringValue  
I then make an instance of the window d.Edit_iSecure. When the window shows all 
the values are displayed and are correct. 
When the window closes I pass the values to the appropriate rs field like 
rs.Field("Device_Type").StringValue = d.Device_Type.Uppercase

I then update rs, check db.error. (When I look in the debugger all the values 
are set correctly to the changes and updates that were made in the window)
Then I update db and check db.error

I am now using 2010 r 4.1. This code had been working for the last two years 
and it is now failing to update the record. There are no errors occurring. If I 
change the "Label" back to "StaticText" and run in 2009 r5.1 this code works as 
expected.

Here is a bit of the code that is doing this work. Anyone else experience this 
behavior in this release?
I think I would need to make a huge sql statement to resolve this.
Any suggestions?


Code:  Dim fldSchema, hdrList As String
  Dim date_str as New date
  Dim Hour_str, Minutes_str, Seconds_str As String
  Dim rs as RecordSet
  
  Dim db as mySQLCommunityServer
  db=New mySQLCommunityServer
  db.host = MyDBHost 
  db.port = MyDBPort
  db.databaseName = MyDBName
  db.userName = MyDBLoginID
  db.Password = MyDBPassword
  db.TimeOut = 600
  
  // create a new Dialog
  dim d as new Edit_DB_item_Dialog
  dim sql as String = my_sql_search + " " + TablesListBox.Text // build a SQL 
query to extract information about the Record
  sql = sql + " WHERE  " + database_row_identifyer + "=" + Str(a_id)
  
  Hour_str = Format(date_str.Hour, "00")
  Minutes_str = Format(date_str.Minute, "00")
  Seconds_str = Format(date_str.Second, "00")
  
  // Get the Table Field Schema
  fldSchema = DBREturnFieldSchema(Table_Name)
  hdrList = fldSchema
  
  If NOT db.Connect Then
  MsgBox "This iSecure record could not be edited: " + db.ErrorMessage
  return
  End
  
  // pass the query to SQLSelect to get the information from the database
  rs = db.SQLSelect(sql)
  
  if rs = nil or rs.EOF then
  MsgBox "This record could not be edited: " + db.ErrorMessage
  return
  end if
  
  // initialize the dialog with the information for the item
  d.Record_number_Field.Text = str(a_iSecure_id)
  d.Device_Type = rs.Field("Device_Type").StringValue
  d.Room_PLAR = rs.Field("Room_PLAR").StringValue
  d.Calling_DN = rs.Field("Calling_DN").StringValue
  d.Building = rs.Field("Building").StringValue
  d.Floor = rs.Field("Floor").StringValue
  d.Location = rs.Field("Location").StringValue
  d.Main_id = rs.Field("Main_id").StringValue
  d.Data_IO_IP = rs.Field("Data_IO_IP").StringValue
  d.Description = rs.Field("Description").StringValue
  
  d.Main_Desk = rs.Field("Main_Desk").StringValue
  d.Phone_1 = rs.Field("Phone_1").StringValue
  d.Phone_2 = rs.Field("Phone_2").StringValue
  d.Phone_3 = rs.Field("Phone_3").StringValue
  d.Phone_4 = rs.Field("Phone_4").StringValue
  d.Phone_5 = rs.Field("Phone_5").StringValue
  d.Phone_6 = rs.Field("Phone_6").StringValue
  d.Which_Port = rs.Field("Which_Port").StringValue
  d.Bit_Position = rs.Field("Bit_Position").StringValue
  d.int_Combined = rs.Field("int_Combined").StringValue
  
  d.GP1_PLAR = rs.Field("GP1_PLAR").StringValue
  d.GP2_PLAR = rs.Field("GP2_PLAR").StringValue
  d.GP3_PLAR = rs.Field("GP3_PLAR").StringValue
  d.GP4_PLAR = rs.Field("GP4_PLAR").StringValue
  
  d.Input_set = rs.Field("Input").IntegerValue
  d.Input_ack = rs.Field("Input_ack").IntegerValue
  d.Start_TOD = rs.Field("Input_start_TOD").IntegerValue
  d.Stop_TOD = rs.Field("Input_stop_TOD").IntegerValue
  
  'd.GP1_Device_Type = rs.Field("GP1_Device_Type").StringValue
  'd.GP2_Device_Type = rs.Field("GP2_Device_Type").StringValue
  'd.GP3_Device_Type = rs.Field("GP3_Device_Type").StringValue
  'd.GP4_Device_Type = rs.Field("GP4_Device_Type").StringValue
  
  // show the dialog to the user
  if not d.Edit_iSecure then
  Send_Message("Record " + str(a_id) + " update was canceled.")
  // the user clicked Cancel, so return
  return
  end if
  
  if db.Error then
  MsgBox "The table: " + Table_Name + " item could not be edited: " + 
db.ErrorMessage
  Send_Message( "The table: " + Table_Name + " item could not be edited: " + 
db.ErrorMessage)
  return
  end if
  
  // tell the RecordSet we are about to start making changes
  rs.Edit
  
  if db.Error then
  MsgBox "The record could not be updated: " + db.ErrorMessage
  Send_Message( "The DB table: " + Table_Name + " item could not be updated: " 
+ db.ErrorMessage)
  
  return
  end if
  
  // update the information in the RecordSet with that in the dialog
  rs.Field("Device_Type").StringValue = d.Device_Type.Uppercase
  rs.Field("Room_PLAR").StringValue = d.Room_PLAR
  rs.Field("Calling_DN").StringValue = d.Calling_DN
  rs.Field("Building").StringValue = d.Building
  rs.Field("Floor").StringValue = d.Floor
  rs.Field("Location").StringValue = d.Location
  rs.Field("Main_id").StringValue = d.Main_id
  rs.Field("Data_IO_IP").StringValue = d.Data_IO_IP
  rs.Field("Description").StringValue = d.Description
  
  rs.Field("Which_Port").StringValue = d.Which_Port
  rs.Field("Bit_Position").StringValue = d.Bit_Position
  rs.Field("int_Combined").StringValue = d.int_Combined
  
  rs.Field("Main_Desk").StringValue = d.Main_Desk
  rs.Field("Phone_1").StringValue = d.Phone_1
  rs.Field("Phone_2").StringValue = d.Phone_2
  rs.Field("Phone_3").StringValue = d.Phone_3
  rs.Field("Phone_4").StringValue = d.Phone_4
  rs.Field("Phone_5").StringValue = d.Phone_5
  rs.Field("Phone_6").StringValue = d.Phone_6
  
  rs.Field("GP1_PLAR").StringValue = d.GP1_PLAR
  rs.Field("GP2_PLAR").StringValue = d.GP2_PLAR
  rs.Field("GP3_PLAR").StringValue = d.GP3_PLAR
  rs.Field("GP4_PLAR").StringValue = d.GP4_PLAR
  
  rs.Field("GP1_Device_Type").StringValue = d.GP1_Device_Type.Uppercase
  rs.Field("GP2_Device_Type").StringValue = d.GP2_Device_Type.Uppercase
  rs.Field("GP3_Device_Type").StringValue = d.GP3_Device_Type.Uppercase
  rs.Field("GP4_Device_Type").StringValue = d.GP4_Device_Type.Uppercase
  
  rs.Field("Input").IntegerValue = d.Input_set
  rs.Field("Input_ack").IntegerValue = d.Input_ack
  rs.Field("Input_start_TOD").IntegerValue = d.Start_TOD
  rs.Field("Input_stop_TOD").IntegerValue = d.Stop_TOD
  
  // tell the RecordSet to update the record
  rs.Update
  if db.Error then
  MsgBox "The record could not be updated: " + db.ErrorMessage
  Send_Message( "The DB table: " + Table_Name + " item could not be updated: " 
+ db.ErrorMessage)
  
  return
  end if
  
  // make the change permanent in the database
  db.Commit
  
  if db.Error then
  MsgBox "The record could not be updated: " + db.ErrorMessage
  Send_Message( "The DB table: " + Table_Name + " item could not be updated: " 
+ db.ErrorMessage)
  
  return
  end if
  
  db.close
  rs.Close
  
  if db.Error then
  MsgBox "The record could not be edited: " + db.ErrorMessage
  Send_Message( "The DB table: " + Table_Name + " item could not be edited: " + 
db.ErrorMessage)
  
  return
  end if
   
                             Top                swort          Post subject: 
Re: MySQL db w/recordset not working 2010 r4.1Posted: Thu Nov 18, 2010 9:53 pm  
                       
Joined: Mon May 31, 2010 5:35 am
Posts: 269                - Wich platform are you on?

- Did you NOT missed a name of a control (while renaming or changing to "Label" 
instead of "StaticText") ?

- What does the Send_Message function do ? Anything wich uses a label or 
statictext ?      
_________________
Hey Its Me SWORT.
Running the annoying "Windows Vista" on SuperB "Dell Inspirion laptop"
Running the cool "Linux Ubuntu 10.04 LTS" on SuperB "XXoDD dual core 8gb 10TB 
Desktop" as it says "extra extrodinary ODD"
I dont like to use PLUGINS (altrough i have a few)  
                             Top                 carlfitzsimmons          Post 
subject: Re: MySQL db w/recordset not working 2010 r4.1Posted: Thu Nov 18, 2010 
11:36 pm                         
Joined: Tue Sep 19, 2006 5:10 pm
Posts: 113                OSX 10.6

All StaticText was changed to Label for 2010 r4.1 and to StaticText for 2009 
r5.1

Send Message sends messages to a text file, no StaticText at all.

All inputs come from TextFields   
                             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