I am working on a signout system I have a good start but am trying to solve a small problem.
Signing out equipment I fill part of a form with student data from the dataset with Fillby, fill the other half with equipment data using Fillby1 I then save this combined data to my Access 2007 Database using a OleDb.OleDbConnection.
This works great!
to sign equipment back in I use the following;
This also works great with one exception Unless I restart my app the equipment I just signed out will not gives me my "that equipment was not signed out" yet I know the record is in the access db and after restarting my app it will find ant sign the equipment in.Code:Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Do Me.Show() Me.Activate() Dim BARCODE As String = InputBox("Enter Equipment Barcode") 'storing the text entered in a string If BARCODE <> "" Then 'Load the Record into my form 'Fillby loads record where RETURNDATE IS NULL and BARCODE = @BARCODE Try Me.SignedOutEquipmentTableAdapter.FillBy(Me.SignoutDataSet.SignedOutEquipment, BARCODE) If Me.SignoutDataSet.SignedOutEquipment.Rows.Count = 0 Then MsgBox("That Item Was Not Signed Out", MsgBoxStyle.Critical, "Equipment Not Signed OUT") End If 'Here I insert todays date into the form Dim now As Date = Date.Now now.ToString("F") RETURNDATE.Text = now 'Now I want to Update the record with the RETURNDATE Field 'and save it back to the Database Using dbConn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Documents and Settings\wfrisbie\My Documents\Visual Studio 2008\Projects\Signout\Signout\Signout.accdb") dbConn.Open() Using Command As New OleDbCommand("UPDATE SignedOutEquipment " + _ "SET RETURNDATE = #" + Me.RETURNDATE.Text + "# WHERE BARCODE = '" + _ Me.BARCODE.Text & "' AND RETURNDATE is NULL", dbConn) Command.ExecuteNonQuery() End Using dbConn.Close() End Using Catch ex As OleDbException MessageBox.Show(ex.Message) Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try Else : Me.Close() Exit Do End If Loop End Sub
I can not find out anywhere how to reload the dataset from access I have tried several ways Clear/Reset ect. none seems to work.
So I was thinking that Maybe I could use the OleDb.OleDbConnection to get the records directly from the Access DB instead of the Dataset something like;
I stopped right there because A. I'm not sure I am on the right track B. I started thinking about binding sources for my form. C. I am a Novice and am really not sure how to proceed.Code:Me.Show() Me.Activate() Dim BARCODE As String = InputBox("Enter Equipment Barcode") 'storing the text entered in a string If BARCODE <> "" Then 'Load the Record into my form Try Dim dbconn As OleDb.OleDbConnection dbconn = New OleDb.OleDbConnection dbconn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Documents and Settings\wfrisbie\My Documents\Visual Studio 2008\Projects\Signout\Signout\Signout.accdb" dbconn.Open() Dim db As String = ("Select IDNUM,LNAME,FNAME,PHONE,EMail,BARCODE,TYPE,DESCR,DATEOUT,DUEDATE,RETURNDATE FROM SignedOutEquipment WHERE BARCODE=@BARCODE and RETURNDATE is NULL")
If someone has some answers or suggestions I would really appreciate them as well as a push in the right direction.
as I said I am new at this learning as I go
Sorry this was a long post but I wanted to clearly explain my issue
Thanks




Reply With Quote