I have a database with a table that stores values into two columns.
on my form i have a dataset table adapter and binding source control.
now i would like the ability to allow the user to enter a value in tbox1 and tbox2 and search for those values from the database table.
i need to know if a value in column1 and a value in column2 exist in the same row.
any help is appreciated...TIA

Data Controls!!
Forum Coder
Ok I'm not sure if this is the optimal solutoin for my situation but this is what I have come up with:
if
(employmentConnector.SupportsSearching != true) MessageBox.Show("Cannot search the list."); else{
int foundIndex = employmentConnector.Find("UserPasword", this.uPasswordTextBox.Text); if (foundIndex > -1) MessageBox.Show(String.Format("Found @: {0}", foundIndex.ToString())); else MessageBox.Show("Password was not found.");}
This does obtain the desired performance for me; however, if there is a better way I'd like to know :D
-willhelm
kfarley215
Hi this should do what you are after. It is all done by code though it may not be how you want to do it but you get the idea.
Also you will only need one TextBox to achive what you are trying to do. :)
Add this at the top of your form:
using
System.Data.OleDb; string cnString = "PROVIDER=Microsoft.Jet.Oledb.4.0; Data Source=" +@"E:\Database.mdb"; string sqlString = "SELECT * " +
"FROM Table1 " +
"WHERE Field1 AND Field2 = '" + txtTextBox1.Text + "';"; OleDbConnection cn = new OleDbConnection(cnString);
OleDbDataAdapter da = new OleDbDataAdapter(sqlString, cn);
DataTable dt = new DataTable();
cn.Open();
this.grdData.DataSource = dt;da.Fill(dt);
cn.Close();
Any question just shout.
Martin
Shailesh
well what I'm using is SQL express sorry for not mentioning that.
I am using the filter method of my binding source control to filter the typed data set like so:
employmentConnector.Filter = (
String.Format(
"UserName='{0}'", this.uNameTextBox.Text));And this works as intended. But I need to understand what would I check to see if there were any results at all returned or better yet, how do I just check this list myself so I can search it to know if 2 different values(val1="bob" val2="crocket") exist under one row in seperate columns
Do I need to create an object that represents the same data in the database then create a collection
of these objects that implements the: System.ComponentModel.BindingList<myObject>
Thanks for the help!
-willhelm