Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,943 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,405 people online right now. Registration is fast and FREE... Join Now!




Can't find any errors

 
Reply to this topicStart new topic

Can't find any errors, This is a short program that uses Access as a database.

oakhill84604
16 Dec, 2007 - 02:55 AM
Post #1

New D.I.C Head
*

Joined: 18 Nov, 2007
Posts: 4


My Contributions
This program seemed to work when it was on a Citrix server. I then downloaded it to my local drive and I couldn't run it again. Maybe one of you can see whee my error is. Thanks

Option Strict On

Public Class frmMemHelper2
Inherits System.Windows.Forms.Form
Dim strMemConnection As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & _
Application.StartupPath & "\memory.mdb"
Dim strSQLMem As String 'All records and all fields from Memory Table
Dim dtMem As New DataTable 'Global DataTable - seen by all subroutines
Dim intTotalRows As Integer 'How many rows are there
Dim intCurrentRow As Integer 'Where I am in the table (which row)
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents btnTop As System.Windows.Forms.Button
Friend WithEvents btnPrevious As System.Windows.Forms.Button
Friend WithEvents btnNext As System.Windows.Forms.Button
Friend WithEvents txtTitle As System.Windows.Forms.TextBox
Friend WithEvents lblTitle As System.Windows.Forms.Label
Friend WithEvents txtAuthor As System.Windows.Forms.TextBox
Friend WithEvents lblAuthor As System.Windows.Forms.Label
Friend WithEvents lblPublisher As System.Windows.Forms.Label
Friend WithEvents txtPublisher As System.Windows.Forms.TextBox
Friend WithEvents txtStuff As System.Windows.Forms.TextBox
Friend WithEvents btnBottom As System.Windows.Forms.Button
Friend WithEvents btnQuit As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.btnTop = New System.Windows.Forms.Button
Me.btnPrevious = New System.Windows.Forms.Button
Me.btnNext = New System.Windows.Forms.Button
Me.btnBottom = New System.Windows.Forms.Button
Me.btnQuit = New System.Windows.Forms.Button
Me.txtStuff = New System.Windows.Forms.TextBox
Me.txtTitle = New System.Windows.Forms.TextBox
Me.txtAuthor = New System.Windows.Forms.TextBox
Me.lblAuthor = New System.Windows.Forms.Label
Me.lblTitle = New System.Windows.Forms.Label
Me.lblPublisher = New System.Windows.Forms.Label
Me.txtPublisher = New System.Windows.Forms.TextBox
Me.SuspendLayout() '
'btnTop '
Me.btnTop.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnTop.ForeColor = System.Drawing.Color.Black
Me.btnTop.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.btnTop.Location = New System.Drawing.Point(16, 304)
Me.btnTop.Name = "btnTop"
Me.btnTop.Size = New System.Drawing.Size(72, 24)
Me.btnTop.TabIndex = 0
Me.btnTop.Text = "Top"
Me.btnTop.TextAlign = System.Drawing.ContentAlignment.BottomCenter
'
'btnPrevious
'
Me.btnPrevious.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnPrevious.ForeColor = System.Drawing.Color.Black
Me.btnPrevious.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.btnPrevious.Location = New System.Drawing.Point(104, 304)
Me.btnPrevious.Name = "btnPrevious"
Me.btnPrevious.Size = New System.Drawing.Size(72, 24)
Me.btnPrevious.TabIndex = 1
Me.btnPrevious.Text = "Prev"
Me.btnPrevious.TextAlign = System.Drawing.ContentAlignment.BottomCenter
'
'btnNext
'
Me.btnNext.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnNext.ForeColor = System.Drawing.Color.Black
Me.btnNext.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.btnNext.Location = New System.Drawing.Point(192, 304)
Me.btnNext.Name = "btnNext"
Me.btnNext.Size = New System.Drawing.Size(72, 24)
Me.btnNext.TabIndex = 2
Me.btnNext.Text = "Next"
Me.btnNext.TextAlign = System.Drawing.ContentAlignment.BottomCenter
'
'btnBottom
'
Me.btnBottom.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnBottom.ForeColor = System.Drawing.Color.Black
Me.btnBottom.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.btnBottom.Location = New System.Drawing.Point(280, 304)
Me.btnBottom.Name = "btnBottom"
Me.btnBottom.Size = New System.Drawing.Size(72, 24)
Me.btnBottom.TabIndex = 3
Me.btnBottom.Text = "Bottom"
Me.btnBottom.TextAlign = System.Drawing.ContentAlignment.BottomCenter
'
'btnQuit
'
Me.btnQuit.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnQuit.ForeColor = System.Drawing.Color.Black
Me.btnQuit.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.btnQuit.Location = New System.Drawing.Point(456, 304)
Me.btnQuit.Name = "btnQuit"
Me.btnQuit.Size = New System.Drawing.Size(72, 24)
Me.btnQuit.TabIndex = 9
Me.btnQuit.Text = "Quit"
'
'txtStuff
'
Me.txtStuff.AutoSize = False
Me.txtStuff.BackColor = System.Drawing.SystemColors.ControlLight
Me.txtStuff.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtStuff.ForeColor = System.Drawing.Color.Black
Me.txtStuff.Location = New System.Drawing.Point(16, 104)
Me.txtStuff.Multiline = True
Me.txtStuff.Name = "txtStuff"
Me.txtStuff.Size = New System.Drawing.Size(512, 176)
Me.txtStuff.TabIndex = 10
Me.txtStuff.Text = ""
'
'txtTitle
'
Me.txtTitle.BackColor = System.Drawing.SystemColors.ControlLight
Me.txtTitle.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtTitle.ForeColor = System.Drawing.Color.Black
Me.txtTitle.Location = New System.Drawing.Point(64, 24)
Me.txtTitle.Multiline = True
Me.txtTitle.Name = "txtTitle"
Me.txtTitle.Size = New System.Drawing.Size(464, 20)
Me.txtTitle.TabIndex = 11
Me.txtTitle.Text = ""
'
'txtAuthor
'
Me.txtAuthor.BackColor = System.Drawing.SystemColors.ControlLight
Me.txtAuthor.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtAuthor.ForeColor = System.Drawing.Color.Black
Me.txtAuthor.Location = New System.Drawing.Point(64, 64)
Me.txtAuthor.Multiline = True
Me.txtAuthor.Name = "txtAuthor"
Me.txtAuthor.Size = New System.Drawing.Size(184, 20)
Me.txtAuthor.TabIndex = 12
Me.txtAuthor.Text = ""
Me.txtAuthor.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'lblAuthor
'
Me.lblAuthor.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblAuthor.ForeColor = System.Drawing.Color.Black
Me.lblAuthor.Location = New System.Drawing.Point(8, 64)
Me.lblAuthor.Name = "lblAuthor"
Me.lblAuthor.Size = New System.Drawing.Size(48, 16)
Me.lblAuthor.TabIndex = 13
Me.lblAuthor.Text = "Author:"
Me.lblAuthor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'lblTitle
'
Me.lblTitle.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTitle.ForeColor = System.Drawing.Color.Black
Me.lblTitle.Location = New System.Drawing.Point(8, 24)
Me.lblTitle.Name = "lblTitle"
Me.lblTitle.Size = New System.Drawing.Size(32, 16)
Me.lblTitle.TabIndex = 14
Me.lblTitle.Text = "Title:"
Me.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'lblPublisher
'
Me.lblPublisher.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblPublisher.ForeColor = System.Drawing.Color.Black
Me.lblPublisher.Location = New System.Drawing.Point(264, 64)
Me.lblPublisher.Name = "lblPublisher"
Me.lblPublisher.Size = New System.Drawing.Size(64, 16)
Me.lblPublisher.TabIndex = 16
Me.lblPublisher.Text = "Publisher:"
Me.lblPublisher.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'txtPublisher
'
Me.txtPublisher.BackColor = System.Drawing.SystemColors.ControlLight
Me.txtPublisher.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtPublisher.ForeColor = System.Drawing.Color.Black
Me.txtPublisher.Location = New System.Drawing.Point(336, 64)
Me.txtPublisher.Multiline = True
Me.txtPublisher.Name = "txtPublisher"
Me.txtPublisher.Size = New System.Drawing.Size(192, 20)
Me.txtPublisher.TabIndex = 15
Me.txtPublisher.Text = ""
Me.txtPublisher.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'frmMemHelper2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(544, 345)
Me.Controls.Add(Me.lblPublisher)
Me.Controls.Add(Me.txtPublisher)
Me.Controls.Add(Me.lblTitle)
Me.Controls.Add(Me.lblAuthor)
Me.Controls.Add(Me.txtAuthor)
Me.Controls.Add(Me.txtTitle)
Me.Controls.Add(Me.txtStuff)
Me.Controls.Add(Me.btnQuit)
Me.Controls.Add(Me.btnBottom)
Me.Controls.Add(Me.btnNext)
Me.Controls.Add(Me.btnPrevious)
Me.Controls.Add(Me.btnTop)
Me.Name = "frmMemHelper2"
Me.Text = "Memory Helper2 By Tony Miller
Me.ResumeLayout(False)

End Sub

#End Region



Private Sub frmMemHelper2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dtMem.Clear()
strSQLMem = "SELECT * FROM MEMORY"
Dim dataAdapter As New OleDb.OleDbDataAdapter(strSQLMem, strMemConnection)
dataAdapter.Fill(dtMem)
dataAdapter.Dispose()
intTotalRows = dtMem.Rows.Count
intCurrentRow = 1
DisplayRecord()
End Sub
Private Sub DisplayRecord()
Me.txtTitle.Text = CStr(dtMem.Rows(intCurrentRow)("title"))
Me.txtAuthor.Text = CStr(dtMem.Rows(intCurrentRow)("author"))
Me.txtPublisher.Text = CStr(dtMem.Rows(intCurrentRow)("publisher"))
Me.txtStuff.Text = CStr(dtMem.Rows(intCurrentRow)("stuff"))
End Sub

Private Sub btnTop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTop.Click
intCurrentRow = 1 'set the current row to 1 to go to top record
DisplayRecord() 'display the current record
End Sub

Private Sub btnBottom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBottom.Click
intCurrentRow = intTotalRows - 1 'set the current row to -1 to go to bottom row
DisplayRecord() 'dosplay the bottom record
MessageBox.Show("You are the last record") 'message box to let user know this is the last record
End Sub


Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
intCurrentRow = intTotalRows - 1 'go to previos row
If intCurrentRow = 0 Then
intCurrentRow = 1
End If
DisplayRecord() 'Display the previous record
End Sub


Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
intCurrentRow = intCurrentRow + 1 'go to next row
If intCurrentRow = intTotalRows Then
intCurrentRow = intTotalRows - 1
MessageBox.Show("There are know more Records") 'informuser there are no more records
End If
DisplayRecord() 'display the next record.
End Sub


Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
Close()
End Sub
End Class

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 04:49PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month