Parse numbers in singe textbox for query
Posted
by Joshua Slocum
on Stack Overflow
See other posts from Stack Overflow
or by Joshua Slocum
Published on 2010-04-15T19:34:47Z
Indexed on
2010/04/15
19:43 UTC
Read the original article
Hit count: 307
I’ve built a webform in Visual Web Developer Express 2008 to help me with my work. I use a webform to run query requests that are emailed to me. The inputs are in this format
12312 12312
12312 12312
12312 12312
12312 12312
I enter the first number in a textbox and the second number in another textbox and click a button that runs a query and returns the results in a gridview(single row).
string strConn, strSQL;
strConn = AppConfig.Connection
strSQL = 'select fields from table where FirstNum=:FirstNum and SecondNum=:SecondNum';
using (OracleConnection cn = new OracleConnection(strConn))
{
OracleCommand cmd = new OracleCommand(strSQL, cn);
cmd.Parameters.AddWithValue(":FirstNum", txtFirstNum.Text);
cmd.Parameters.AddWithValue(":SeconNum",
txtSecondNum.Text);
cn.Open();
using (OracleDataReader rdr = cmd.ExecuteReader())
{
dgResults.DataSource = rdr;
dgResults.DataBind();
}
cn.Close();
}
I had an idea to help me speed up my work. I’d like to be able to past both numbers in a single textbox
( like this 12312 12312 )
and have the code parse out the nubmers for the query. Or even better would be to past all of them in a multiline textbox like this
12312 12312
12312 12312
12312 12312
12312 12312
And have them all parsed and the query run for each line and the results all output to one gridview. I’m just not sure how to approach this. Any suggestions would be appreciated.
Thank you.
© Stack Overflow or respective owner