A below is how i got it setup, I know it's very wrong but I hope you can understand what I'm trying to do.
Basically, I have one searchtextbox, one searchbutton and a combox which I edited and inserted two strings RMAnumber and SerialNumber.
I want to beable to get the result no matter if I search by a RMAnumber or a SerialNumber. I know that my setup conflicts between RMA and SerialNumber, so I guess this is where a combobox comes in, right But i don't know how to program a combobox to work with a searchbutton and a searchtextbox. Please someone guide me through this. THank you
SELECT ID, Company, RMANumber, SerialNumber, CustomerProblem, Motherboard, Harddrive, WindowsOS, Problem, Resolution, Date, ResolutionDate FROM RMATable
WHERE (RMAnumber = @RMAnumber)
WHERE (SerialNumber = @SerialNumber)
rMATableTableAdapter.FillByrMADatabaseDataSet.RMATable, searchtextbox.Text);
rMATableTableAdapter.FillBySerialNumber(rMADatabaseDataSet.RMATable, searchtextbox.Text);

Help i'm trying to query from sql with tableadapter
IanG
Yes, I got my combobox with RMANumber String and SerialNumber string. The problem is; I don't know how to program it. Are there any sample code
Gordon7502
hi,
if i understood correct , you need to search the selected column name in the combobox according to the value entered in a textbox, you can do something like this in your command
OleDbCommand cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * From Mytable Where @cboboxselecteditem = @txtbxValue";
cmd.Parameters.AddWithValue("cboboxselecteditem", this.comboBox1.SelectedItem.ToString());
cmd.Parameters.AddWithValue("txtbxValue", this.textBox1.Text);
//ToDo : add the rest of the connection code
hope this helps
MOK123
{
OleDbCommand cmd =
new OleDbCommand();cmd.CommandType =
CommandType.Text;cmd.CommandText =
"select * From Customer Where @cboboxselecteditem = @txtbxValue";cmd.Parameters.AddWithValue(
"cboboxselecteditem", this.comboBox1.SelectedItem.ToString());cmd.Parameters.AddWithValue(
"txtbxValue", this.textBox1.Text); //ToDo : add the rest of the connection code}
It doesn't work, I received an error message below
Error 1 The type or namespace name 'DbCommand' could not be found (are you missing a using directive or an assembly reference ) C:\Documents and Settings\admin\My Documents\Visual Studio 2005\Projects\searchformexample\searchformexample\Form1.cs 35 13 searchformexample
Gregory_N
I suggest you compose two dynamic queries for this. One will be executed when the RMA Number is selected on the combobox, and the other when the Serial Number is selected from the combobox.
Hope that helps.
-Ver
MNorbex
hi,
sure it will not work you need to use "system.Data.OleDB" , (but that depends on which database you use ) you can't use this without a connection string any way you will find some tutorials on how to featch data to your app in this link
http://msdn2.microsoft.com/en-us/library/ms171918(VS.80).aspx
hope this helps