Here is some of my code, but it's quite long. I've trimmed it to just the sections that deal with data reading and writing, as I'm pretty confident that the error is in there somewhere.
NOTE: SchedBox(col,row) is an array of custom control that is similar to a cell in a grid. Quick List of subroutines and functions: Sub OpenSession Opens Session to Unidata Sub CloseSession Closes Session to Unidata Sub SelectRecords Selects Records in Unidata File Sub FillDataTable Fills the 'Schedule1' DataTable Sub Sched_Text_Changed Called when scheduling text is changed in text boxes in custom control Sub Changed_Cust_Info Called when customer text is changed in a text box in custom control Function GetNewID Returns 'NewCounter' Sub WriteData Writes a Record to Unidata File Function LoadSchedFileData Returns 'OkToWrite' Thanks for any help you may have. - Dave --------------------------------------------------------------------------------- Public Sub OpenSession() ' ' Create a session to work with ' Session = CreateObject(UV_SESSION_OBJECT) If Session Is Nothing Then ' NB. Errors will be reported by Visual Basic Exit Sub ' End program End If Session.HostName = "<hostname>" Session.AccountPath = "<accountpath>" Session.UserName = "<username>" Session.Password = "<password>" ' Session.Connect() If Session.isactive Then ' Continue with the program, then close the session. If Session.HostType = UVT_UNIX Then 'MsgBox("You are connected to the UNIX server") End If Else ' Check for session errors - display dialog box with error code If Session.error <> UVE_NOERROR Then MsgBox("Unable to open connection due to error#: " & Session.error) End If End If End Sub Public Sub CloseSession() SchedFile.CloseFile() SchedFile = Nothing Session.Disconnect() If Session.isactive Then ' Continue with the program, then close the session. MsgBox("You are still connected. Attempting one last time to disconnect.") Session.disconnect() End If End Sub Public Sub SelectRecords() ' Open a Select List SchedFile = Session.OpenFile("SCHED_DATA") SelectListObj = Session.SelectList(0) Session.Command.Text = "SSELECT SCHED_DATA BY DEL_DATE BY SEQ_NO" Session.command.exec() Session.command.text = "SAVE-LIST SD.JUNK" Session.command.exec() SelectListObj.GetList("SD.JUNK") End Sub Public Sub FillDataTable() Dim SchedRec As Object SchedFile.RecordID = SelectListObj.Next Do While Not SelectListObj.LastRecordRead ' Read a record and check for errors SchedFile.Read() If SchedFile.Error <> UVE_NOERROR Then MsgBox("Error reading from file (" & SchedFile.Error & ")") Exit Do End If ' Load the Schedule1 table ' SchedRec = SchedFile.Record Dim anyRow As DataRow = Schedule1.NewRow anyRow("ID") = SchedFile.RecordID anyRow("JOB_NO") = SchedRec.Field(1).StringValue If SchedRec.Field(2).StringValue <> "" Then anyRow("DEL_DATE") = CDate(Session.Oconv(SchedRec.Field(2).StringValue, "D2/")) Else anyRow("DEL_DATE") = System.DBNull.Value End If ' anyRow("CUST_NAME") = SchedRec.Field(3).StringValue anyRow("CITY") = SchedRec.Field(4).StringValue anyRow("STATE") = SchedRec.Field(5).StringValue anyRow("SEQ_NO") = SchedRec.Field(6).StringValue If SchedRec.Field(7).StringValue <> "" Then anyRow("PRM_DATE") = Session.Oconv(SchedRec.Field(7).StringValue, "D2/") Else anyRow("PRM_DATE") = System.DBNull.Value End If If SchedRec.Field(8).StringValue <> "" Then anyRow("PRM_TIME") = SchedRec.Field(8).StringValue Else anyRow("PRM_TIME") = System.DBNull.Value End If anyRow("TYPE") = SchedRec.Field(9).StringValue anyRow("HOURS") = SchedRec.Field(10).StringValue anyRow("CODE") = SchedRec.Field(11).StringValue anyRow("COLOR") = SchedRec.Field(12).StringValue anyRow("SYMBOL") = SchedRec.Field(13).StringValue anyRow("EMP") = SchedRec.Field(14).StringValue anyRow("REL_NO") = SchedRec.Field(15).StringValue anyRow("PRIORITY") = SchedRec.Field(16).StringValue anyRow("TRK_NO") = SchedRec.Field(17).StringValue Schedule1.Rows.Add(anyRow) ' ' SchedFile.RecordID = SelectListObj.Next ' Get the next record ID Loop End Sub Private Sub Sched_Text_Changed(ByVal sender As Object, ByVal e As System.EventArgs) ' Dim x As Integer Dim TempBox As TextBox Dim CustomerName, City, ReleaseNo As String TempBox = CType(sender, TextBox) FromBox = TempBox.Parent If FromBox.PrmDtInfo.Text <> "" Or FromBox.PrmTmInfo.Text <> "" Then SchedBox(FromBox.Column, FromBox.Row).PrmDtInfo.BackColor = Color.Red SchedBox(FromBox.Column, FromBox.Row).PrmTmInfo.BackColor = Color.Red Else SchedBox(FromBox.Column, FromBox.Row).PrmDtInfo.BackColor = Color.White SchedBox(FromBox.Column, FromBox.Row).PrmTmInfo.BackColor = Color.White End If ' For x = 0 To Schedule1.Rows.Count - 1 If Schedule1.Rows(x).Item("ID") = SchedBox(FromBox.Column, FromBox.Row).ID Then Schedule1.Rows(x).Item("CUST_NAME") = SchedBox(FromBox.Column, FromBox.Row).CustName Schedule1.Rows(x).Item("CODE") = SchedBox(FromBox.Column, FromBox.Row).CodeInfo.Text Schedule1.Rows(x).Item("PRIORITY") = SchedBox(FromBox.Column, FromBox.Row).PriorityInfo.Text Schedule1.Rows(x).Item("CITY") = SchedBox(FromBox.Column, FromBox.Row).City Schedule1.Rows(x).Item("PRM_DATE") = SchedBox(FromBox.Column, FromBox.Row).PrmDtInfo.Text Schedule1.Rows(x).Item("PRM_TIME") = SchedBox(FromBox.Column, FromBox.Row).PrmTmInfo.Text Schedule1.Rows(x).Item("TYPE") = SchedBox(FromBox.Column, FromBox.Row).TypeInfo.Text Schedule1.Rows(x).Item("HOURS") = SchedBox(FromBox.Column, FromBox.Row).HoursInfo.Text Schedule1.Rows(x).Item("EMP") = SchedBox(FromBox.Column, FromBox.Row).EmpInfo.Text Schedule1.Rows(x).Item("REL_NO") = SchedBox(FromBox.Column, FromBox.Row).RelNo Schedule1.Rows(x).Item("TRK_NO") = SchedBox(FromBox.Column, FromBox.Row).TruckInfo.Text ' WriteData(SchedBox(FromBox.Column, FromBox.Row).ID) End If Next End Sub Public Sub Change_Cust_Info(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim testbox As TextBox Dim NewCustomer, NewCity, NewState, NewRelNo As String testbox = CType(sender, TextBox) FromBox = testbox.Parent If FromBox.CustInfo.Text <> "" Then If IsDBNull(SchedBox(FromBox.Column, FromBox.Row).CustName) Then NewCustomer = InputBox("State: ", "Enter Customer Name Here") Else NewCustomer = InputBox("Customer: ", SchedBox(FromBox.Column, FromBox.Row).CustName) End If If NewCustomer <> "" Then SchedBox(FromBox.Column, FromBox.Row).CustName = NewCustomer End If ' If IsDBNull(SchedBox(FromBox.Column, FromBox.Row).City) Then NewCity = InputBox("City: ", "Town") Else NewCity = InputBox("City: ", SchedBox(FromBox.Column, FromBox.Row).City) End If If NewCity <> "" Then SchedBox(FromBox.Column, FromBox.Row).City = NewCity End If ' If IsDBNull(SchedBox(FromBox.Column, FromBox.Row).State) Then NewState = InputBox("State: ", "STATE") Else Try NewState = InputBox("State: ", SchedBox(FromBox.Column, FromBox.Row).State) Catch NewState = InputBox("State: ", "STATE") End Try End If If NewState <> "" Then SchedBox(FromBox.Column, FromBox.Row).State = NewState End If ' If IsDBNull(SchedBox(FromBox.Column, FromBox.Row).RelNo) Then NewState = InputBox("Release Number: ", "00000000000") Else NewRelNo = InputBox("Release Number: ", SchedBox(FromBox.Column, FromBox.Row).RelNo) End If If NewRelNo <> "" Then SchedBox(FromBox.Column, FromBox.Row).RelNo = NewRelNo End If ' SchedBox(FromBox.Column, FromBox.Row).CustInfo.Text = SchedBox(FromBox.Column, FromBox.Row).CustName & vbCrLf & SchedBox(FromBox.Column, FromBox.Row).City & ", " & SchedBox(FromBox.Column, FromBox.Row).State & vbCrLf & SchedBox(FromBox.Column, FromBox.Row).RelNo & " - " & SchedBox(FromBox.Column, FromBox.Row).ID ' Sched_Text_Changed(sender, System.EventArgs.Empty) Else MsgBox("Invalid Cell." & vbCrLf & "Please select another." & vbCrLf & "Thank you.", MsgBoxStyle.Information, "Cell Modification Error") End If End Sub Public Function GetNewID(ByVal NewCounter) Dim SchedDictFile As Object Dim counter As Integer ' OpenSession() ' SchedDictFile = Session.OpenFile("DICT SCHED_DATA") SchedDictFile.RecordID = "COUNTER" SchedDictFile.Read() ' counter = SchedDictFile.record.field(1).stringvalue counter += 1 SchedDictFile.record.field(1).stringvalue = counter ' SchedDictFile.write() ' SchedDictFile.CloseFile() SchedDictFile = Nothing Session.Disconnect() If Session.isactive Then ' Continue with the program, then close the session. MsgBox("You are still connected. Attempting one last time to disconnect.") Session.disconnect() If Session.isactive Then ' Continue with the program, then close the session. MsgBox("After an attempt to disconnect, you are still connected. Please alert Amy to fix this problem.") Else MsgBox("You are now disconnected.") End If End If ' NewCounter = counter ' Return NewCounter End Function Public Sub WriteData(ByVal RecID As String) Dim SchedRec As Object Dim dtModifiedData As DataTable Dim Row As Integer Dim ThisRow As Integer Dim OkToWrite As Boolean = False Dim anyRow As DataRow = Schedule1.NewRow ' Open the session OpenSession() ' Update the DataSource SchedFile = Session.OpenFile("FURN_SCHED_DATA") SchedFile.RecordID = RecID ' Load the Schedule1 table OkToWrite = False Try OkToWrite = LoadSchedFileData(RecID) Catch anyRow("ID") = RecID anyRow("JOB_NO") = SchedBox(0, 0).JobNo anyRow("DEL_DATE") = System.DBNull.Value anyRow("CUST_NAME") = SchedBox(0, 0).CustName anyRow("CITY") = SchedBox(0, 0).City anyRow("STATE") = "" anyRow("SEQ_NO") = "0" anyRow("PRM_DATE") = System.DBNull.Value anyRow("PRM_TIME") = System.DBNull.Value anyRow("TYPE") = System.DBNull.Value anyRow("HOURS") = "0h" anyRow("CODE") = System.DBNull.Value anyRow("COLOR") = System.DBNull.Value anyRow("SYMBOL") = System.DBNull.Value anyRow("EMP") = "1" anyRow("REL_NO") = SchedBox(0, 0).RelNo anyRow("PRIORITY") = "N" anyRow("TRK_NO") = System.DBNull.Value Schedule1.Rows.Add(anyRow) ' OkToWrite = LoadSchedFileData(RecID) End Try ' If OkToWrite Then Try SchedFile.Write() Catch MsgBox("WriteData Subroutine:" & vbCrLf & "Could not write SchedFile.Record.ID# " & RecID & " to the Database") End Try End If If SchedFile.error <> 0 Then MsgBox("An error has occurred in the WriteData subroutine." & vbCrLf & "Could not update changed record." & vbCrLf & "Error# (" & SchedFile.error & ")" & vbCrLf & "Please notify system administrator immediately.", MsgBoxStyle.Critical, "Update Status") Else 'MsgBox("SchedFile.Error = " & SchedFile.Error) End If ' Close the session CloseSession() End Sub Public Function LoadSchedFileData(ByVal RecId As String) Dim ThisRow As Integer Dim Flag As Boolean = False For ThisRow = 0 To Schedule1.Rows.Count If CInt(Schedule1.Rows(ThisRow).Item("ID")) = CInt(RecId) Then ' Job Number SchedFile.Record.field(1).stringvalue = Schedule1.Rows(ThisRow).Item("JOB_NO") ' Delivery Date If IsDBNull(Schedule1.Rows(ThisRow).Item("DEL_DATE")) Then SchedFile.record.field(2).stringvalue = "" Else SchedFile.Record.field(2).stringvalue = CStr(Session.Iconv(Schedule1.Rows(ThisRow).Item("DEL_DATE"), "D2/")) End If ' Customer Name If IsDBNull(Schedule1.Rows(ThisRow).Item("CUST_NAME")) Then SchedFile.record.field(3).stringvalue = "" Else SchedFile.Record.field(3).stringvalue = Schedule1.Rows(ThisRow).Item("CUST_NAME") End If ' City If IsDBNull(Schedule1.Rows(ThisRow).Item("CITY")) Then SchedFile.record.field(4).stringvalue = "" Else SchedFile.Record.field(4).stringvalue = Schedule1.Rows(ThisRow).Item("CITY") End If ' State If IsDBNull(Schedule1.Rows(ThisRow).Item("STATE")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(5).stringvalue = Schedule1.Rows(ThisRow).Item("STATE") End If ' Sequence Number Try SchedFile.Record.field(6).stringvalue = Schedule1.Rows(ThisRow).Item("SEQ_NO") Catch SchedFile.record.field(6).stringvalue = Nothing End Try ' Promised Date If IsDBNull(Schedule1.Rows(ThisRow).Item("PRM_DATE")) Then SchedFile.record.field(7).stringvalue = "" Else SchedFile.Record.field(7).stringvalue = Session.Iconv(Schedule1.Rows(ThisRow).Item("PRM_DATE"), "D2/") End If ' Promised Time If IsDBNull(Schedule1.Rows(ThisRow).Item("PRM_TIME")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(8).stringvalue = Schedule1.Rows(ThisRow).Item("PRM_TIME") End If ' Type If IsDBNull(Schedule1.Rows(ThisRow).Item("TYPE")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(9).stringvalue = Schedule1.Rows(ThisRow).Item("TYPE") End If ' Hours If IsDBNull(Schedule1.Rows(ThisRow).Item("HOURS")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(10).stringvalue = Schedule1.Rows(ThisRow).Item("HOURS") End If ' Code If IsDBNull(Schedule1.Rows(ThisRow).Item("CODE")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(11).stringvalue = Schedule1.Rows(ThisRow).Item("CODE") End If ' Color If IsDBNull(Schedule1.Rows(ThisRow).Item("COLOR")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(12).stringvalue = Schedule1.Rows(ThisRow).Item("COLOR") End If ' Symbol If IsDBNull(Schedule1.Rows(ThisRow).Item("SYMBOL")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(13).stringvalue = Schedule1.Rows(ThisRow).Item("SYMBOL") End If ' Employees If IsDBNull(Schedule1.Rows(ThisRow).Item("EMP")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(14).stringvalue = Schedule1.Rows(ThisRow).Item("EMP") End If ' Release (Picker) Number If IsDBNull(Schedule1.Rows(ThisRow).Item("REL_NO")) Then SchedFile.record.field(15).stringvalue = "" Else SchedFile.Record.field(15).stringvalue = Schedule1.Rows(ThisRow).Item("REL_NO") End If ' Priority If IsDBNull(Schedule1.Rows(ThisRow).Item("PRIORITY")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(16).stringvalue = Schedule1.Rows(ThisRow).Item("PRIORITY") End If ' Truck Number If IsDBNull(Schedule1.Rows(ThisRow).Item("TRK_NO")) Then SchedFile.record.field(8).stringvalue = "" Else SchedFile.Record.field(17).stringvalue = Schedule1.Rows(ThisRow).Item("TRK_NO") End If ' Flag = True Exit For End If Next ' Return Flag End Function -----Original Message----- I'm having trouble with a scheduling program I'm writing in VB.net, on a WinXPpro system, using UniObjects, that extracts and writes data to a file in our Unidata 6.0.3 system on an AIX 5.1L system. The trouble that I'm having is that the data is getting corrupted. As the screen doesn't rebuild after a data save, I don't 'see' the problem until I restart the program the next time around, and data is re-read from the database. I've been through my program 3 times, and can't find an error. I'm assuming at this point that the error is outside my program, as I ran the same test data through the program 5 times, and it only corrupted the data 3 times. The other two it worked flawlessly. If it was an error in my program, it shouldn't ever work right, should it? Also, the program treats every record equally, but the data is intermittently corrupted, some records process fine, others get corrupted. Some fields are lost all together. Fortunately it's still in test mode, so we haven't lost any real data yet. The data is doing things like this: Record 1: Record 2: DelDate: 03/18/04 03/18/04 <--OK SeqNo: 3 3 <--OK Type: F 0 <----These two are mixed together (* see below) Hours: 0h hF <---/ Code: - <===== This one is GONE!!!! Color: Blue WBlu <----These two are mixed together (* see below) Symbol: W e <---/ Emp: 1 <===== This one is GONE!!!!! RelNo: 01234567001 N0123456700 <----These two are mixed together (* see below) Priority: N 1 <---/ (* HERE!) At first, I thought that the data was being broken up at the wrong points, but after a closer look, it appears that this is happening. In each three line group: Line1: Starts with the first character of line two, and loses it's last character. Line2: Loses it's first character to line 1, and gains the last character of line 1 at the end of it's data. Line3: Data is gone (unless it's a <space> character) It's really crazy. Anyone have any ideas for this one? If so, any help is appreciated. Thanks, Dave Notice of Confidentiality: The information included and/or attached in this electronic mail transmission may contain confidential or privileged information and is intended for the addressee. Any unauthorized disclosure, reproduction, distribution or the taking of action in reliance on the contents of the information is prohibited. If you believe that you have received the message in error, please notify the sender by reply transmission and delete the message without copying or disclosing it. Thank you. -- u2-users mailing list [EMAIL PROTECTED] http://www.oliver.com/mailman/listinfo/u2-users