tomanderson91
Member
- Joined
- Dec 17, 2009
- Messages
- 13
- Programming Experience
- Beginner
Hello, I am making a small application that connects to a database and gets the information displays it in a few labels and text boxes..
I want to add a search feature so it only shows results based on the search, but I have no idea where to start. Please help
I have added the code I have so far.
I want to add a search feature so it only shows results based on the search, but I have no idea where to start. Please help
I have added the code I have so far.
VB.NET:
Imports System.Data
Public Class frmMain
Dim inc As Integer
Dim MaxRows As Integer
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Tom\Documents\Visual Studio 2008\Projects\CameraFormatFinder\CameraFormatFinder.mdb;Persist Security Info=True;Jet OLEDB:Database Password=jjtrtg78"
sql = "SELECT * FROM tblCameraFormats"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "CameraFormats")
con.Open()
MessageBox.Show("Connected")
con.Close()
MessageBox.Show("Disconnected")
lblCameraName.Text = ds.Tables("CameraFormats").Rows(0).Item(1)
lblCameraType.Text = ds.Tables("CameraFormats").Rows(0).Item(2)
txtDefaultFormat.Text = ds.Tables("CameraFormats").Rows(0).Item(3)
txtCameraHelp.Text = ds.Tables("CameraFormats").Rows(0).Item(4)
MaxRows = ds.Tables("CameraFormats").Rows.Count
inc = -1
End Sub
Private Sub NavigateRecords()
lblCameraName.Text = ds.Tables("CameraFormats").Rows(inc).Item(1)
lblCameraType.Text = ds.Tables("CameraFormats").Rows(inc).Item(2)
txtDefaultFormat.Text = ds.Tables("CameraFormats").Rows(inc).Item(3)
txtCameraHelp.Text = ds.Tables("CameraFormats").Rows(inc).Item(4)
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MessageBox.Show("End of Formats", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
Private Sub cmdLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLast.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
Else
MessageBox.Show("End of Formats", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
Private Sub cmdLastResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLastResult.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub
Private Sub cmdFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFirst.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub
Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
End Sub
End Class