I'm fairly new to the VS world and am looking to create to a simple search in an Access 2000 database, using ADO.NET. The database has a simple employee information table. Fields are SS#, Lastname, Firstname, etc. What I would like to do is create an ASP.NET page with a text box and submit button that a user can put their SS# into, hit submit and it returns a single record that corresponds to the SS# inputted by the user. SS# happens to be the primary key in the database. I can return all records fine using an OleDbDataAdapter and a DataSet. Just need a little help with the SQL statement to return only the records that match the SS#. Thanks!
Platform: WinXP Pro
If you're using the OleDbDataAdapter, most probably you have drag&dropped it in a form. Right-click it and select Configure Data Adapter. In the dialog for the SQL statement, enter something like the following:
SELECT * FROM Employees WHERE SSN=@SSN
The code to fill the dataset should be:
oleDbDataAdapter1.SelectCommand.Parameters.Add("@SSN", this.txtSSN.Text); oleDbDataAdapter1.Fill(dataSet1);
This way you're passing the SSN parameter to the query before filling the dataset.
Dig Deeper on Win Development Resources
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ...
Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers.
Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand.
Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.
Start the conversation
0 comments