Select statement in Asp.Net project?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code on my pageLoad event:



taComp = new dsCompTableAdapters.CompTableAdapter();
dtComp = new dsComp.CompDataTable();
taComp.Fill(dtComp);
WbGrid.DataSource = dtComp;

if (!this.IsPostBack)
{
WbGrid.DataBind();
}


OK the above works fine, but , i have a search textBox which i want someone
to search for a specific record in my comp table,.... how can i allow someone
to search for that record ?

they type some text in my search textBox, they click a button, and i want to
run an sql statement somehow against my datatable/tableAdapter/dataset to
retrieve all matching records...

can anyone help me?
 
Hi,

I guess you'll need to configure taComp adequately (its SelectCommand) - add
a parameter or create dynamic sql statements.
 
Hi,
well the problem is that if i add the parameter, i can't use something like:
select * from comp where Name like '%@param1%'

when i try to call taComp.fill(dtComp); the extra parameter that should
appear after dtComp is not there anymore, if i remove the (like) keyword and
use = instead it is ok. I need a closest match type of sql on this.

And i can't get access to the SelectCommand from my code? How can i replace
that SelectCommand at runtime?

It used to be so easy with sqlDataAdapter controls, with Visual Studio 2003,
now it is a pain just getting a simple select going with Visual Studio 2005

Can you help out? How can a user expect to know a piece of information
exactly how it should be typed in the search box? i need that like keyword
sql select statement for searching a table with 5000 records.

Miha Markic said:
Hi,

I guess you'll need to configure taComp adequately (its SelectCommand) - add
a parameter or create dynamic sql statements.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

ARTMIC said:
I have the following code on my pageLoad event:



taComp = new dsCompTableAdapters.CompTableAdapter();
dtComp = new dsComp.CompDataTable();
taComp.Fill(dtComp);
WbGrid.DataSource = dtComp;

if (!this.IsPostBack)
{
WbGrid.DataBind();
}


OK the above works fine, but , i have a search textBox which i want
someone
to search for a specific record in my comp table,.... how can i allow
someone
to search for that record ?

they type some text in my search textBox, they click a button, and i want
to
run an sql statement somehow against my datatable/tableAdapter/dataset to
retrieve all matching records...

can anyone help me?
 
Ok never mind,
i guess the only way to use a "true" search is to have a stored procedure on
the SQL Server and then calling it, so that the Where MyField like
'%somedata%'; works inside the web project.

Miha Markic said:
Hi,

I guess you'll need to configure taComp adequately (its SelectCommand) - add
a parameter or create dynamic sql statements.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

ARTMIC said:
I have the following code on my pageLoad event:



taComp = new dsCompTableAdapters.CompTableAdapter();
dtComp = new dsComp.CompDataTable();
taComp.Fill(dtComp);
WbGrid.DataSource = dtComp;

if (!this.IsPostBack)
{
WbGrid.DataBind();
}


OK the above works fine, but , i have a search textBox which i want
someone
to search for a specific record in my comp table,.... how can i allow
someone
to search for that record ?

they type some text in my search textBox, they click a button, and i want
to
run an sql statement somehow against my datatable/tableAdapter/dataset to
retrieve all matching records...

can anyone help me?
 
ArtMic,

Did you try it first in the Query analyzer what you want to achieve, that
you can always use in any DataAdapter select statement.

Cor

ARTMIC said:
Hi,
well the problem is that if i add the parameter, i can't use something
like:
select * from comp where Name like '%@param1%'

when i try to call taComp.fill(dtComp); the extra parameter that should
appear after dtComp is not there anymore, if i remove the (like) keyword
and
use = instead it is ok. I need a closest match type of sql on this.

And i can't get access to the SelectCommand from my code? How can i
replace
that SelectCommand at runtime?

It used to be so easy with sqlDataAdapter controls, with Visual Studio
2003,
now it is a pain just getting a simple select going with Visual Studio
2005

Can you help out? How can a user expect to know a piece of information
exactly how it should be typed in the search box? i need that like keyword
sql select statement for searching a table with 5000 records.

Miha Markic said:
Hi,

I guess you'll need to configure taComp adequately (its SelectCommand) -
add
a parameter or create dynamic sql statements.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

ARTMIC said:
I have the following code on my pageLoad event:



taComp = new dsCompTableAdapters.CompTableAdapter();
dtComp = new dsComp.CompDataTable();
taComp.Fill(dtComp);
WbGrid.DataSource = dtComp;

if (!this.IsPostBack)
{
WbGrid.DataBind();
}


OK the above works fine, but , i have a search textBox which i want
someone
to search for a specific record in my comp table,.... how can i allow
someone
to search for that record ?

they type some text in my search textBox, they click a button, and i
want
to
run an sql statement somehow against my datatable/tableAdapter/dataset
to
retrieve all matching records...

can anyone help me?
 
Back
Top