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
1 1185
Hey,
I believe I figured this one out. Just needed to create a temporary table. -
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)
-
temp = New Global.ADODB.Recordset
-
Try
-
temp.Open("SELECT * FROM ImageData WHERE Area = '" & Area & "' and Control = '" & Controller & "' ", CN)
-
-
DateBox.Text = temp.Fields("Date").Value
-
InitialsBox.Text = temp.Fields("Initials").Value
-
PartIDBox.Text = temp.Fields("PartID").Value
-
LotNumberBox.Text = temp.Fields("LotNumber").Value
-
ProcessBox.Text = temp.Fields("Process").Value
-
AreaBox.Text = temp.Fields("Area").Value
-
StageBox.Text = temp.Fields("Stage").Value
-
UniqueIDBox.Text = temp.Fields("DateTimeIdentifier_UniqueSystemID").Value
-
CommentsBox.Text = temp.Fields("Comments").Value
-
If temp.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
-
-
'Check to see if record is in the database - this way it won't crash on blank or broken entry.
-
Dim EntryExists As Boolean = True
-
Try
-
CN = New ADODB.Connection
-
CN.Open(ADImageConnection)
-
RS = New ADODB.Recordset
-
RS.Open("SELECT * FROM ImageData WHERE DateTimeIdentifier_UniqueSystemID = '" & UniqueID & "' ", CN)
-
Catch
-
'tell user record isn't in database, turn off errorvariable
-
MsgBox("Record not found")
-
EntryExists = False
-
End Try
-
CN.Close()
-
-
'if it was there, delete it from the database and write a new entry with the new info.
-
'If EntryExists Then
-
-
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").Value() = 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")
-
-
temp.MoveNext()
-
-
DateBox.Text = temp.Fields("Date").Value
-
InitialsBox.Text = temp.Fields("Initials").Value
-
PartIDBox.Text = temp.Fields("PartID").Value
-
LotNumberBox.Text = temp.Fields("LotNumber").Value
-
ProcessBox.Text = temp.Fields("Process").Value
-
AreaBox.Text = temp.Fields("Area").Value
-
StageBox.Text = temp.Fields("Stage").Value
-
UniqueIDBox.Text = temp.Fields("DateTimeIdentifier_UniqueSystemID").Value
-
CommentsBox.Text = temp.Fields("Comments").Value
-
If temp.Fields("Control").Value = "YES" Then
-
Thecontrolbox.Text = "Controlled"
-
Else
-
Thecontrolbox.Text = "Uncontrolled"
-
End If
-
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
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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
...
|
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...
|
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
|
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)"...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |