Quantcast
Viewing all articles
Browse latest Browse all 12583

Ms-Access Search text box C#

I have the following c# code and I want to click on Search and be able to search by lastname


                OleDbConnection cnn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\srye\Desktop\Report_SendInMailBody\Employee Database Merge.accdb");
                DataTable ds = new DataTable();
                OleDbDataAdapter da = new OleDbDataAdapter(@"SELECT [FirstName], [LastName], [JobTitle], [Employee Email],[Manager], [Managers Email], [Location], [Status]
                                                FROM tblExsitingEEs where tblExsitingEEs.[LastName]= " + (txtSearch.Text), cnn);

                da.Fill(ds);
                dataGridView1.DataSource = ds;

When I run this I get an error saying there is a missing parameter if I remove the where clause and it works but I get all employees, I want to be able to do a search where the where clause has the lastname= or lastname like

How can I do this with C# in a windows form I have created in C# using MS-access?


shawnrye



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>