473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stepping through a record set

Hi,
I'm working on an applet that allows a user to step through the results of a query and edit the information.

I have it so that you can click one button to get the image and another to update the record, however, I cannot figure out how to keep the recordset open in a way so that when I click the update button it moves to the next entry.

Any help or insight would be greatly appreciated
Thanks,
Steve

The current code looks like this:
Private Sub GetImageButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetImageButton.Click

FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
Do Until LineInput(1) = "**ADImageLocation**"
Loop
Dim ADImageLocation As String = LineInput(1)
FileClose(1)

FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
Do Until LineInput(1) = "**ADImageConnection**"
Loop
Dim ADImageConnection As String = LineInput(1)
FileClose(1)
Dim Area As String
Dim Controller As String
Controller = "No"
Area = AreaBox.Text
CN = New ADODB.Connection
CN.Open(ADImageConnection)
RS = New Global.ADODB.Recordset

Try
RS.Open("SELECT * FROM ImageData WHERE Area = '" & Area & "' and Control = '" & Controller & "' ", CN)

RS.MoveNext()

DateBox.Text = RS.Fields("Date").Value
InitialsBox.Text = RS.Fields("Initials").Value
PartIDBox.Text = RS.Fields("PartID").Value
LotNumberBox.Text = RS.Fields("LotNumber").Value
ProcessBox.Text = RS.Fields("Process").Value
AreaBox.Text = RS.Fields("Area").Value
StageBox.Text = RS.Fields("Stage").Value
UniqueIDBox.Text = RS.Fields("DateTimeIdentifier_UniqueSystemID").Val ue
CommentsBox.Text = RS.Fields("Comments").Value
If RS.Fields("Control").Value = "YES" Then
Thecontrolbox.Text = "Controlled"
Else
Thecontrolbox.Text = "Uncontrolled"
End If

Catch
MsgBox("Record Not Found")

End Try

'Get Next rs

UniqueID = UniqueIDBox.Text
Try
ImageDisplay.Image = System.Drawing.Image.FromFile(ADImageLocation & UniqueID & ".jpeg")
ImageDisplay.Visible = True
ImageDisplay.SizeMode = PictureBoxSizeMode.StretchImage
Catch
MsgBox("Image Not Found")
End Try

End Sub


Private Sub UpdateRecordButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateRecordButton.Click
Dim Area As String
Dim Controller As String
Controller = "No"
Area = AreaBox.Text
'get connection strings from setup file
FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
Do Until LineInput(1) = "**ADImageLocation**"
Loop
Dim ADImageLocation As String = LineInput(1)
FileClose(1)

FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
Do Until LineInput(1) = "**ADImageConnection**"
Loop
Dim ADImageConnection As String = LineInput(1)
FileClose(1)

UniqueID = UniqueIDBox.Text

CN = New ADODB.Connection
CN.Open(ADImageConnection)
RS = New ADODB.Recordset
RS.Open("DELETE FROM ImageData WHERE DateTimeIdentifier_UniqueSystemID = '" & UniqueID & "' ", CN)
' CN.Close()
Try
CN = New ADODB.Connection
CN.Open(ADImageConnection)
RS = New ADODB.Recordset
RS.Open("select * from ImageData ", CN, 1, 2)
RS.AddNew()
RS.Fields("DateTimeIdentifier_UniqueSystemID").Val ue() = UniqueID
RS.Fields("Date").Value = DateBox.Text
RS.Fields("Initials").Value = InitialsBox.Text
RS.Fields("PartID").Value = PartIDBox.Text
RS.Fields("LotNumber").Value = LotNumberBox.Text
RS.Fields("Process").Value = ProcessBox.Text
If Thecontrolbox.Text = "Controlled" Then
RS.Fields("Control").Value = "YES"
ElseIf Thecontrolbox.Text = "Uncontrolled" Then
RS.Fields("Control").Value = "NO"
End If

RS.Fields("Area").Value = AreaBox.Text
RS.Fields("Stage").Value = StageBox.Text
RS.Fields("Comments").Value = CommentsBox.Text
RS.Fields("ImageName").Value = UniqueID & ".Jpeg"
RS.Fields("Keywords").Value = UniqueIDBox.Text & " , " & DateBox.Text & " , " & InitialsBox.Text & " , " & PartIDBox.Text & " , " & LotNumberBox.Text & " , " & ProcessBox.Text & Thecontrolbox.Text & " , " & AreaBox.Text & " , " & StageBox.Text & " , " & CommentsBox.Text
RS.Update()
CN.Close()
'if the emergency form isnt open yet, open it!
Catch
MsgBox("There has been a connection error. Please contact your network administrator and try again later.")
End Try
If CurrentErrorNumber = 1 Then
Dim StartEmergency As New Emergency
StartEmergency.Show()
ADILogo.Image = System.Drawing.Image.FromFile("C:\Program Files\ADImage\networkdown.bmp")
End If ' end the 'start emergency if its not open

UniqueIDBox.Text = ""
DateBox.Text = ""
InitialsBox.Text = ""
PartIDBox.Text = ""
LotNumberBox.Text = ""
ProcessBox.Text = ""
Thecontrolbox.Text = Nothing
'AreaBox.Text = ""
StageBox.Text = ""
CommentsBox.Text = ""
ImageDisplay.Image.Dispose()
ImageDisplay.Image = Nothing

'Indicating to the user that the image has been updated.
MsgBox("Image data has been updated", MsgBoxStyle.OkOnly, "Image Data Updated")

End Sub
Aug 28 '08 #1
1 1185
Hey,

I believe I figured this one out. Just needed to create a temporary table.

Expand|Select|Wrap|Line Numbers
  1. Private Sub GetImageButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetImageButton.Click
  2.  
  3.         FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
  4.         Do Until LineInput(1) = "**ADImageLocation**"
  5.         Loop
  6.         Dim ADImageLocation As String = LineInput(1)
  7.         FileClose(1)
  8.  
  9.         FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
  10.         Do Until LineInput(1) = "**ADImageConnection**"
  11.         Loop
  12.         Dim ADImageConnection As String = LineInput(1)
  13.         FileClose(1)
  14.         Dim Area As String
  15.         Dim Controller As String
  16.         Controller = "No"
  17.         Area = AreaBox.Text
  18.         CN = New ADODB.Connection
  19.         CN.Open(ADImageConnection)
  20.         temp = New Global.ADODB.Recordset
  21.         Try
  22.             temp.Open("SELECT * FROM ImageData WHERE Area = '" & Area & "' and Control = '" & Controller & "' ", CN)
  23.  
  24.             DateBox.Text = temp.Fields("Date").Value
  25.             InitialsBox.Text = temp.Fields("Initials").Value
  26.             PartIDBox.Text = temp.Fields("PartID").Value
  27.             LotNumberBox.Text = temp.Fields("LotNumber").Value
  28.             ProcessBox.Text = temp.Fields("Process").Value
  29.             AreaBox.Text = temp.Fields("Area").Value
  30.             StageBox.Text = temp.Fields("Stage").Value
  31.             UniqueIDBox.Text = temp.Fields("DateTimeIdentifier_UniqueSystemID").Value
  32.             CommentsBox.Text = temp.Fields("Comments").Value
  33.             If temp.Fields("Control").Value = "YES" Then
  34.                 Thecontrolbox.Text = "Controlled"
  35.             Else
  36.                 Thecontrolbox.Text = "Uncontrolled"
  37.             End If
  38.  
  39.         Catch
  40.             MsgBox("Record Not Found")
  41.  
  42.         End Try
  43.  
  44.         'Get Next rs
  45.  
  46.         UniqueID = UniqueIDBox.Text
  47.         Try
  48.             ImageDisplay.Image = System.Drawing.Image.FromFile(ADImageLocation & UniqueID & ".jpeg")
  49.             ImageDisplay.Visible = True
  50.             ImageDisplay.SizeMode = PictureBoxSizeMode.StretchImage
  51.         Catch
  52.             MsgBox("Image Not Found")
  53.         End Try
  54.  
  55.     End Sub
  56.  
  57. Private Sub UpdateRecordButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateRecordButton.Click
  58.         Dim Area As String
  59.         Dim Controller As String
  60.         Controller = "No"
  61.         Area = AreaBox.Text
  62.         'get connection strings from setup file
  63.         FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
  64.         Do Until LineInput(1) = "**ADImageLocation**"
  65.         Loop
  66.         Dim ADImageLocation As String = LineInput(1)
  67.         FileClose(1)
  68.  
  69.         FileOpen(1, "C:\Program Files\ADImage\ADImageSetup.txt", OpenMode.Input)
  70.         Do Until LineInput(1) = "**ADImageConnection**"
  71.         Loop
  72.         Dim ADImageConnection As String = LineInput(1)
  73.         FileClose(1)
  74.  
  75.         UniqueID = UniqueIDBox.Text
  76.  
  77.         'Check to see if record is in the database - this way it won't crash on blank or broken entry.
  78.         Dim EntryExists As Boolean = True
  79.         Try
  80.             CN = New ADODB.Connection
  81.             CN.Open(ADImageConnection)
  82.             RS = New ADODB.Recordset
  83.             RS.Open("SELECT * FROM ImageData WHERE DateTimeIdentifier_UniqueSystemID = '" & UniqueID & "' ", CN)
  84.         Catch
  85.             'tell user record isn't in database, turn off errorvariable
  86.             MsgBox("Record not found")
  87.             EntryExists = False
  88.         End Try
  89.         CN.Close()
  90.  
  91.         'if it was there, delete it from the database and write a new entry with the new info.  
  92.         'If EntryExists Then
  93.  
  94.         CN = New ADODB.Connection
  95.         CN.Open(ADImageConnection)
  96.         RS = New ADODB.Recordset
  97.         RS.Open("DELETE FROM ImageData WHERE DateTimeIdentifier_UniqueSystemID = '" & UniqueID & "' ", CN)
  98.         CN.Close()
  99.         Try
  100.             CN = New ADODB.Connection
  101.             CN.Open(ADImageConnection)
  102.             RS = New ADODB.Recordset
  103.             RS.Open("select * from ImageData ", CN, 1, 2)
  104.             RS.AddNew()
  105.             RS.Fields("DateTimeIdentifier_UniqueSystemID").Value() = UniqueID
  106.             RS.Fields("Date").Value = DateBox.Text
  107.             RS.Fields("Initials").Value = InitialsBox.Text
  108.             RS.Fields("PartID").Value = PartIDBox.Text
  109.             RS.Fields("LotNumber").Value = LotNumberBox.Text
  110.             RS.Fields("Process").Value = ProcessBox.Text
  111.             If Thecontrolbox.Text = "Controlled" Then
  112.                 RS.Fields("Control").Value = "YES"
  113.             ElseIf Thecontrolbox.Text = "Uncontrolled" Then
  114.                 RS.Fields("Control").Value = "NO"
  115.             End If
  116.  
  117.             RS.Fields("Area").Value = AreaBox.Text
  118.             RS.Fields("Stage").Value = StageBox.Text
  119.             RS.Fields("Comments").Value = CommentsBox.Text
  120.             RS.Fields("ImageName").Value = UniqueID & ".Jpeg"
  121.             RS.Fields("Keywords").Value = UniqueIDBox.Text & " , " & DateBox.Text & " , " & InitialsBox.Text & " , " & PartIDBox.Text & " , " & LotNumberBox.Text & " , " & ProcessBox.Text & Thecontrolbox.Text & " , " & AreaBox.Text & " , " & StageBox.Text & " , " & CommentsBox.Text
  122.             RS.Update()
  123.             CN.Close()
  124.             'if the emergency form isnt open yet, open it!
  125.         Catch
  126.             MsgBox("There has been a connection error.  Please contact your network administrator and try again later.")
  127.         End Try
  128.         If CurrentErrorNumber = 1 Then
  129.             Dim StartEmergency As New Emergency
  130.             StartEmergency.Show()
  131.             ADILogo.Image = System.Drawing.Image.FromFile("C:\Program Files\ADImage\networkdown.bmp")
  132.         End If ' end the 'start emergency if its not open
  133.  
  134.         UniqueIDBox.Text = ""
  135.         DateBox.Text = ""
  136.         InitialsBox.Text = ""
  137.         PartIDBox.Text = ""
  138.         LotNumberBox.Text = ""
  139.         ProcessBox.Text = ""
  140.         Thecontrolbox.Text = Nothing
  141.         'AreaBox.Text = ""
  142.         StageBox.Text = ""
  143.         CommentsBox.Text = ""
  144.         ImageDisplay.Image.Dispose()
  145.         ImageDisplay.Image = Nothing
  146.  
  147.         'Indicating to the user that the image has been updated.
  148.         MsgBox("Image data has been updated", MsgBoxStyle.OkOnly, "Image Data Updated")
  149.  
  150.         temp.MoveNext()
  151.  
  152.         DateBox.Text = temp.Fields("Date").Value
  153.         InitialsBox.Text = temp.Fields("Initials").Value
  154.         PartIDBox.Text = temp.Fields("PartID").Value
  155.         LotNumberBox.Text = temp.Fields("LotNumber").Value
  156.         ProcessBox.Text = temp.Fields("Process").Value
  157.         AreaBox.Text = temp.Fields("Area").Value
  158.         StageBox.Text = temp.Fields("Stage").Value
  159.         UniqueIDBox.Text = temp.Fields("DateTimeIdentifier_UniqueSystemID").Value
  160.         CommentsBox.Text = temp.Fields("Comments").Value
  161.         If temp.Fields("Control").Value = "YES" Then
  162.             Thecontrolbox.Text = "Controlled"
  163.         Else
  164.             Thecontrolbox.Text = "Uncontrolled"
  165.         End If
  166.         UniqueID = UniqueIDBox.Text
  167.         Try
  168.             ImageDisplay.Image = System.Drawing.Image.FromFile(ADImageLocation & UniqueID & ".jpeg")
  169.             ImageDisplay.Visible = True
  170.             ImageDisplay.SizeMode = PictureBoxSizeMode.StretchImage
  171.         Catch
  172.             MsgBox("Image Not Found")
  173.         End Try
  174. End Sub
  175.  
Aug 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: pinaki_m77 | last post by:
Hi, I am trying to debug a C++ program using Microsoft VC++ IDE. The program loads a dynamic link library (dll) and later makes calls to functions inside this dll. I want to step inside the code of...
25
by: David C | last post by:
I posted this question, and from the replies, I get the impression that I worded my posting very poorly, so let me try this again. While debugging and stepping through this foreach loop ...
0
by: stand__sure | last post by:
Stepping into a stored procedure used to be fairly straight-forward, but after following the guidance in all 6 or so of the MSDN pages about enabling debugging of stored procedures in SQL Server...
3
by: rodchar | last post by:
hey all, when i step thru the above event here's what I get for RowTypes ?e.Row.RowType Header DataRow (this is in red in the watch window) DataRow (and this is in black) Footer
0
by: =?Utf-8?B?TWlrZSBPS0M=?= | last post by:
VB 2003 As I am stepping through code, I want to see a data table in a grid, so I can easily see the data in the data table. Currently I QuickWatch the data table, then I have to add ".rows(0)"...
7
by: Lyn | last post by:
Is there a solution to this problem? While stepping through code (F8) it would sometimes be helpful to observe changes occurring on the affected form in the Access window. However, the current...
1
by: battlestarguy | last post by:
I have been creating a database that keeps track of the number of tools in our shop. To keep the upkeep of this database simple, I have created buttons that will import all the relevent data from...
3
by: Midnight Marauders | last post by:
Hi all.. I am looking for some assistance on a query. I have a Stored Procedure where I am attemtping to step through the results and return every other nth record.. Here is what I have so...
15
by: postman | last post by:
Any idea why code would work as intended when setting a breakpoint and stepping through it line by line, but won't work correctly at run-time? The code is too much to post, so I hope this summary...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.