3 Replies - 6256 Views - Last Post: 23 September 2010 - 08:02 AM Rate Topic: -----

#1 mjw85   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 01-October 07

Textbox - get specific rows from database based on user entered values

Posted 23 September 2010 - 07:47 AM

I am currently trying to return specific rows from a database based on user-entered information in a textbox (by using a submit button). The data I want to pull from the database are parameters and information I have already created and put into the database.

Currently in the dataclass I have:
private void getExistingMR()
{
OracleConnection conOracle = new OracleConnection(oradb);
 OracleCommand cmdMRID = new OracleCommand("", conOracle);
cmdMRID.CommandText = "SELECT QUANTITY FROM TABLENAME WHERE ITEMID LIKE '%" + txtTextBox.Text + "%'";
OracleDataReader odrMRID;
try
{
conOracle.Open();
odrMRID = cmdMRID.ExecuteReader();
odrMRID.Read();
conOracle.Dispose();
}
catch //(Exception ex)
{
 //MessageBox.Show(ex.Message.ToString());
 }

// Return the datatable
          



... which I kind of understand.
What I am confused about is how the dataclass will know where to pull "txtTextBox.Text" from, since it is in another form.
I have the following code in the actual form, not sure if I am headed in the right direction or not. I think the solution would be converting the textbox entered data to a string, which I think I may have done, but how to enter this into the dataclass above?


 private void btnSearch_Click(object sender, EventArgs e)
{
int SearchId;
SearchId = Convert.ToInt32(txtTextBox.Text);
txtTextBox.Text = SearchId.ToString();
}



ANY suggestions/help is appreciated! :surrender:

Is This A Good Question/Topic? 0
  • +

Replies To: Textbox - get specific rows from database based on user entered values

#2 FlashM   User is offline

  • D.I.C Lover
  • member icon

Reputation: 383
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: Textbox - get specific rows from database based on user entered values

Posted 23 September 2010 - 07:54 AM

How many forms you said you have? If there is one form containing the data and the other form that retrieves data from database based on input parameters that live in textboxes on other form, then you'll first have to somehow get them, and pass them to database query...
Was This Post Helpful? 2
  • +
  • -

#3 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Textbox - get specific rows from database based on user entered values

Posted 23 September 2010 - 07:55 AM

Quote

how the dataclass will know where to pull "txtTextBox.Text" from, since it is in another form.


It won't. You'll have to give the dataclass some way to get that information.
Maybe the other form raises an event with the text as the arguments, to trigger the search. Maybe your program.cs file has a public property you can make as a means to tunnel into the text. maybe the form doing the search, created the form with the textbox and thus knows of that *instance* of that form and therefore can use the textbox.

Quick and easy custom events
Bulding an application - Part 1
Building an application - Part 2

Debugging tutorial
Was This Post Helpful? 2
  • +
  • -

#4 mjw85   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 01-October 07

Re: Textbox - get specific rows from database based on user entered values

Posted 23 September 2010 - 08:02 AM

View PostFlashM, on 23 September 2010 - 06:54 AM, said:

How many forms you said you have? If there is one form containing the data and the other form that retrieves data from database based on input parameters that live in textboxes on other form, then you'll first have to somehow get them, and pass them to database query...

Thanks for your help.
I am currently using 3 forms:
the forms dataclass, forms rules (which are kind of tied together), and the form where the user will enter the data in the textbox... no forms actually contain the data, for they are stored in an oracle database (as parameters) - so I am trying to pull specific rows from the database table that match the entered id in the textbox
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1