How to make a search and edit for an Access Database?

Maxwell175

Member
Joined
Feb 11, 2012
Messages
12
Location
Pennsylvania, USA
Programming Experience
1-3
Hello all,

I am building a Access database for my bank account. :smash:

I made the database itself, now I need to make the forms. :concern:
Since I know whey more VB.NET then VB for applications. So, can someone give me a code sample or something to start with? :err:

FYI: I have a Access 2007 & Access 2003 database file. :courage:
 
I found some code on the net: :)

VB.NET:
[XCODE=vb]Dim SearchJob As String = TextBox1.Text

        Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Users\Maxwell\Documents\BCPA project\BCPA_Accounting.mdb")
        ' Use wildcard'  
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT Person.Last_Name, Person.First_Name, Person.Addr_ln1, Person.Addr_ln2, Person.City, Person.Zip, Person.State, Person.Email, Person.Membship_status, Person.Member_Key FROM (Person) WHERE UCase([Person].[Last_Name] LIKE (" & Chr(34) & UCase(TextBox1.Text) & Chr(34) & ");")
        ' or Where JobNo='" & SearchJob & "'  


        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "Person")
        DataGridView1.DataSource = myDataSet.Tables("Person").DefaultView
        con.Close()
        con.Dispose()
        myDA.Dispose()
        cmd.Dispose()[/XCODE]


On the line:

myDA.Fill(myDataSet, "Person")


:( :kaioken: :heart-borken:
I get error: InvalidOperationException was unhandled

VB.NET:
Fill: SelectCommand.Connection property has not been initialized.

What is the problem and how do I solve it?
 
Last edited:
The steps are:

1. Execute a query to populate a DataTable.
2. Bind the DataTable to a BindingSource.
3. Bind the BindingSource to your control(s).
4. Use the Filter and Sort properties of the BindingSource to filter and sort the data.
 
The steps are:

1. Execute a query to populate a DataTable.
2. Bind the DataTable to a BindingSource.
3. Bind the BindingSource to your control(s).
4. Use the Filter and Sort properties of the BindingSource to filter and sort the data.

I am sorry if I am being annoying but I don't know how to do any of that. :redface:
 
Back
Top