Results 1 to 4 of 4

Thread: [RESOLVED] Error when entering search key in MS access database ado.net form?!

Threaded View

  1. #1

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Resolved [RESOLVED] Error when entering search key in MS access database ado.net form?!

    Hi everybody…
    I’ve created ado.net access database project form contain 1 table and 5 field.

    The Problem: The search button work only for the first click If I try to put another search key in the textbox and click the search button I’m getting an error code “This causes two bindings in the collection to bind to the same property. Parameter name: binding”
    Code:
    Imports System.Data
    Imports System.Data.OleDb
    
    
    Public Class Form2
        Dim frm As New Form1
        Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & Application.StartupPath & "\data.mdb"
        Dim Conn As New OleDbConnection(ConStr)
        Dim DataSet1 As New DataSet
        Dim SQLstr As String
        Dim m As String
    
    
        Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
            Static m As Integer = 0
            If tbSearch.Text = Trim("") Then Exit Sub
            ExactSearch()
            Conn.Open()
            Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn)
            DataAdapter1.Fill(DataSet1, "store")
            Conn.Close()
            tbSearchResulItemPartNumber.DataBindings.Add("Text", DataSet1, "store.Item Part Number")
            tbSearchResultItemDeascriptions.DataBindings.Add("Text", DataSet1, "store.Item Descriptions")
            tbSearchResultItemLocation.DataBindings.Add("Text", DataSet1, "store.Item Location")
            DataGridView1.DataSource = DataSet1
            DataGridView1.DataMember = "store"
    
            If Me.BindingContext(DataSet1, "store").Count = 0 Then
                MsgBox("No Result, Either the item part number incorrect format or the item not exist in the store ??!! ")
                Form1.Show()
                Me.Close()
            End If
    
            Exit Sub
    
        End Sub
    
        Public Sub ExactSearch()
            SQLstr = "SELECT * FROM store WHERE [Item Part Number ]= '" & tbSearch.Text & "'"
        End Sub
    
        
        Private Sub btnBACK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBACK.Click
            Me.Close()
            Form1.Show()
        End Sub
    End Class
    Any suggestion codes to make the search button get result repeatedly (every time I click) and appear once (result)...

    Regards...
    Last edited by HOTFIX; Nov 2nd, 2008 at 02:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width