Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Moving SqlDataSource to ObjectDataSource. need help

Reply
Thread Tools

Moving SqlDataSource to ObjectDataSource. need help

 
 
Raja
Guest
Posts: n/a
 
      08-31-2006
Hi everybody
I am converting my pages to use ObjectDataSource instead of
SqlDataSource and want to keep the same user interface but have a small
problem.

In a page using SqlDataSource I have a textbox where user can input the
query (whole query in SQL). Then by clicking the search button I was
using it as: SqlDataSource1.SelectCommand = txtQuery.Text.
I want to have the same interface into a converted page where I am
using ObjectDataSource.
How can I do this?

I can probably have a select method where there will a parameter for
every column and then have a textbox for every column in the page where
user can enter search parameters and it may work as well, but I am
using this project only inside the company where only people having the
knowledge of SQL are using it, so they can write their queries fast and
check what they want.

Can someone tell the answer or guide to a link?

Thanks in advance
Raja

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      08-31-2006
You will have to create an object with the job of delivering SQL. The SQL
string will then be sent to the database from the object and run. Since you
are dealing with random FUD, you will likely have to return a Random
DataSet.

NOTE: This is not a good security practice, as anyone with a SQL background
can do major damage to your database with this wide open ability. You should
restrict the account that can run queries this way to only being able to
query tables that it should have access to and stop any security SQL or DDL
from running under this account.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
"Raja" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> Hi everybody
> I am converting my pages to use ObjectDataSource instead of
> SqlDataSource and want to keep the same user interface but have a small
> problem.
>
> In a page using SqlDataSource I have a textbox where user can input the
> query (whole query in SQL). Then by clicking the search button I was
> using it as: SqlDataSource1.SelectCommand = txtQuery.Text.
> I want to have the same interface into a converted page where I am
> using ObjectDataSource.
> How can I do this?
>
> I can probably have a select method where there will a parameter for
> every column and then have a textbox for every column in the page where
> user can enter search parameters and it may work as well, but I am
> using this project only inside the company where only people having the
> knowledge of SQL are using it, so they can write their queries fast and
> check what they want.
>
> Can someone tell the answer or guide to a link?
>
> Thanks in advance
> Raja
>



 
Reply With Quote
 
 
 
 
Ed Hinton
Guest
Posts: n/a
 
      03-14-2008
I know this is an old thread, but in case anyone else stumbles across this trying to do it, there is a VERY easy way to do it. You can create a SelectParameter that will be set to the dynamic SQL query you want to run. Then in your data source, in the SelectMethod and Selectmethod calls, you need to add the extra parameter (first parameter actually). In the SelectMethod, just use what is passed in.

In the SelectCount method (assuming a paged data source), you'll need to replace everything before the "FROM" clause with "SELECT COUNT(*) ". That's it.

I did this so that bound controls I was using could set filter criteria easily or even pass a very complex where clause in the query referencing many things without needing lots of separate parameters for all the different columns or tables referenced, and so I also could easily drop out requested columns if I only want a subset. Because the calling code uses reflection, it all works beautifully.

That said, i echo the caution about security vulnerability. In my case, it is special code-behind code behind my controls that is crafting the query. I do NOT recommend ever just passing whatever a user types in.

From http://www.developmentnow.com/g/8_20...e-need-help.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving Guide Moving Companies Movers Storage linkswanted ASP .Net 0 01-23-2008 01:08 AM
Free Moving Estimate, Local Movers, Long Distance Moving, PackingSupplies, Storage Rental, Home Moving, Apartment Moving, Office Moving,Commercial Moving linkswanted ASP .Net 0 01-06-2008 04:45 AM
Moving to California Moving to L.A linkswanted Digital Photography 3 01-05-2008 04:22 PM
movers los angeles moving storage services movers in L.A companymoving companies moving in calfornia los angeles linkswanted HTML 0 12-21-2007 10:55 PM



Advertisments