Connecting Tech Pros Worldwide Help | Site Map

Updating Oracle Data Field using VB .Net 2003 and C1.Flexgrid

Newbie
 
Join Date: Sep 2009
Posts: 1
#1: Sep 14 '09
Hi all

I was asked from the company i support their intranet with asp to create a vb prog in order to retrive magazine circulations from their oracle server and update the number of circulations if needed to be corrected.
After searching a lot the web i have come up with the following code, apart from the date selection criteria, that works in retrieving and displaying the data as i was asked to do:
Expand|Select|Wrap|Line Numbers
  1.  Dim SrText As String = ""
  2.     Dim SrDate As Date
  3.     Dim RtnYear As Integer
  4.     Dim I As Integer
  5.     Dim MyReader As OracleDataReader
  6.     '[VS1].C1FlexGrid.flexDMBoundImmediate[=3]
  7.     'VS1.Bound=0
  8.  
  9.     Sub FillGrid()
  10.         Year()
  11.         Dim StrMedia As String = ""
  12.  
  13.         Dim MySelect = _
  14.         "SELECT   tbl_media.media_id, media_descr, media_categories_id, " _
  15.         & " mi_yearmonth, mi_date, mi_circulation, mi_id " _
  16.         & " FROM tbl_media, tbl_media_issue " _
  17.         & " WHERE tbl_media.media_id = tbl_media_issue.media_id " _
  18.         & " AND (Tbl_Media.Media_Categories_ID = 2 OR Tbl_Media.Media_Categories_ID = 3)" _
  19.         & " AND Tbl_Media_Issue.MI_Yearmonth = " & RtnYear & " AND Tbl_Media.Media_Descr like '%" & SrText & "%' AND mi_circulation IS NOT NULL ORDER BY tbl_media.media_id, mi_yearmonth"
  20.  
  21.         Dim MyCommand As New OracleCommand(MySelect, OracleCon)
  22.  
  23.         Try
  24.  
  25.             MyReader = MyCommand.ExecuteReader
  26.  
  27.             Me.VS1.Clear(C1.Win.C1FlexGrid.ClearFlags.All)
  28.             Me.VS1.Rows.Count = 1
  29.             Me.VS1.Cols.Count = 1
  30.             Me.VS1.Cols(0).Width = 15
  31.  
  32.             FillData(MyReader)
  33.             Me.VS1.AutoSizeCols()
  34.             Me.Refresh()
  35.         Catch ex As Exception
  36.             MessageBox.Show(ex.ToString, "FillGrid")
  37.         End Try
  38.     End Sub
  39.  
  40.     Private Sub MFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MFileExit.Click
  41.         End
  42.     End Sub
  43.  
  44.     Private Sub Text1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Text1.TextChanged
  45.         SrText = Text1.Text
  46.     End Sub
  47.  
The select year function goes here
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn1.Click
  2.         FillGrid()
  3.     End Sub
  4.  
  5.     Sub FillData(ByVal MyReader As OracleDataReader)
  6.         I = 0
  7.         Dim StrMedia As String
  8.  
  9.         VS1.Cols.Add()
  10.         VS1.Cols(VS1.Cols.Count - 1).Caption = "Κωδικός"
  11.         VS1.Cols(VS1.Cols.Count - 1).Name = "Κωδικός"
  12.  
  13.         VS1.Cols.Add()
  14.         VS1.Cols(VS1.Cols.Count - 1).Caption = "Ονομασία"
  15.         VS1.Cols(VS1.Cols.Count - 1).Name = "Ονομασία"
  16.  
  17.         VS1.Cols.Add()
  18.         VS1.Cols(VS1.Cols.Count - 1).Caption = "Ημερομηνία"
  19.         VS1.Cols(VS1.Cols.Count - 1).Name = "Ημερομηνία"
  20.  
  21.         VS1.Cols.Add()
  22.         VS1.Cols(VS1.Cols.Count - 1).Caption = "Κυκλοφορίες"
  23.         VS1.Cols(VS1.Cols.Count - 1).Name = "Κυκλοφορίες"
  24.  
  25.         Try
  26.             While MyReader.Read
  27.                 I = I + 1
  28.                 Me.VS1.Rows.Add()
  29.                 Me.VS1(Me.VS1.Rows.Count - 1, Me.VS1.Cols("Κωδικός").Index) = MyReader("MI_ID")
  30.                 Me.VS1(Me.VS1.Rows.Count - 1, Me.VS1.Cols("Ονομασία").Index) = MyReader("MEDIA_DESCR")
  31.                 Me.VS1(Me.VS1.Rows.Count - 1, Me.VS1.Cols("Ημερομηνία").Index) = MyReader("MI_DATE")
  32.                 Me.VS1(Me.VS1.Rows.Count - 1, Me.VS1.Cols("Κυκλοφορίες").Index) = MyReader("MI_CIRCULATION")
  33.             End While
  34.         Catch ex As Exception
  35.             MessageBox.Show(ex.ToString, "FillData")
  36.         End Try
  37.     End Sub
  38.  
  39.     Private Sub VS1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VS1.Click
  40.  
  41.     End Sub
  42. End Class

I would like some help with the update statement since i can't find anything in the web that works with the software versions i am using.
In particular i want to match the first row with the table's id number and then update the circulation number for that id. the records in the field can be many depending on the search the user uses.

Thank you in advance

Yours Sincerely
ick
Reply