Showing posts with label background. Show all posts
Showing posts with label background. Show all posts

Thursday, March 8, 2012

"Refresh" an SQLDataSource object programmatically

Background - I have a page that uses a numeric value stored in a Session object variable as the parameter for three different SQLDataSource objects, which provide data to two asp:Repeaters and an asp:DataList. Also, in the Page_Load, I use this value to to seed a stored procedure and an SQLDataReader to populate several unbound Labels. This works fine. In addition, I have a collection of 6 TextBoxes, an unbound Listbox, and two Buttons to allow the user to do searching and selection of potential matches. This basically identifies a new numeric value that I store in the Session variable and PostBack the page (via one of the buttons). This also works fine.

Problem - I have been tasked with taking a different page and adding six textboxes to collect the search values, but to post over to this page, populate the existing search-oriented TextBoxes, adn programmatically triggering the search. Furthermore, I have to detect the number of matching records and, if only 1, have the Repeaters and DataList display the results based on the newly selected record's key numeric value, as well as populating the unbound Labels. I have managed to get all of this accomplished except for programmatically triggering the Repeaters and DataList "refresh". These controls only populate as expected if a button is clicked a subsequent time, which makes sense, since that would trigger a PostBack and the Page_Load uses the new saved numeric key value from the Session.

My history in app development is largely from Windows Forms development (VB6), this is my second foray into Web Form dev with ASP.NET 2.0. I am willing to acceptthat what I am trying to do does not fit into the ASP environment, but I have to think that this is something that has been done before, and (hopefully) there is a way to do what I need.

Any ideas, oh great and wise Forum readers? *smile*

I don't think I have fully understood your problem. But when the user clicks search button you need to refresh the sqldatasource and call your_repeaters_or_datalist.DataBind() to refresh repeaters or datalist. If you have code in Post_Back you don't want to trigger you can include it in
if (!Page.IsPostBack)
{
////your code
}

|||

Thanks for the response. Hopefully this helps clarify my situation: The source page has several text boxes that mirror those on the target page. When a specific button on the source page is clicked, the contents of the source text boxes is written to the Session object and a redirect cross-posts to the target page. The Page_Load on the target page checks IsPostback and if it is a cross-page post, the code checks the origin of the action (via a Session variable), and updates the textboxes on the target page with the search parameters. In code, I poppulate a listbox (with results of a SQL stored procedure) with potential matches. If more than one match is returned, I want it to stop and await user interaction (And I have it at that point.) However, if only one match is returned, I have tried to save the key record value back to the Session object, so it can be available to the SQLDataSources that use it as its source value. This is not occurring.

IIn your response, you mentioned "you need to refresh the sqldatasource and call your_repeaters_or_datalist.DataBind() to refresh". That (refreshing the sqldatasource) is what I am trying to do. How can I get them to refresh without issuing an additional postback to the target page? Is there a method that I need to invoke on the sqldatasource objects to do that? It sounds like I am close, but not quite sure what to do at this point.

|||

Is there a method that I need to invoke on the sqldatasource objects to do that?

yes. Assume DataList control yourdatalist is bound to sqldatasource camDS,call following code to refresh:

camDS.SelectCommand ="searchcam";
camDS.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
camDS.SelectParameters.Add("keyword1","para1 ");
yourdatalist.DataBind();

How can I get them to refresh without issuing an additional postback to the target page?

I don't think this can be achieved without post back since data is saved at the server.

Friday, February 24, 2012

"Live" queries in sql 2005 ?

A colleague was telling me the other day that in Sql Server 2005 there is a
special type of query you can do, whereby it runs in the background and
brings back results automatically, whenever they change. He referred to it
as something called a "live" query, but I'm not sure that's correct
terminology.
In theory you could run such a query, and sit back and watch the results
change in Query Analyser (or wherever). For example if you were monitoring
total sales, you could literally run the query and it would "auto update" in
front of your eyes, as sales increased.
Then you could theoretically write a client application with, say, a grid
which was bound to the "live query" and updated itself magically.
One could write a client app which polled the database every 2 seconds or
whatever, but that's not as efficient as picking up data *only* when it
changes.
Obviously it depends on the client limitations, but has anyone heard of such
a thing in SQL 2005?
Thanks,
Owen"Owen" <spam@.spam.com> wrote in message
news:lZOdnfeFS9oemgbZnZ2dnUVZ8smdnZ2d@.pi
pex.net...
>A colleague was telling me the other day that in Sql Server 2005 there is a
>special type of query you can do, whereby it runs in the background and
>brings back results automatically, whenever they change. He referred to it
>as something called a "live" query, but I'm not sure that's correct
>terminology.
>
Query Notification.
Query Notifications in ADO.NET 2.0
http://msdn.microsoft.com/library/d...otification.asp
David|||"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:uaX3ADllGHA.3740@.TK2MSFTNGP02.phx.gbl...
> "Owen" <spam@.spam.com> wrote in message
> news:lZOdnfeFS9oemgbZnZ2dnUVZ8smdnZ2d@.pi
pex.net...
> Query Notification.
> Query Notifications in ADO.NET 2.0
> http://msdn.microsoft.com/library/d...otification.asp
> David
Sounds about right, thanks very much indeed. !
Owen.
http://www.riptheuglybluevoidfromyourhead.com

Thursday, February 9, 2012

"Change Tracking" with "Update Index in Background" FREEZE ENTERPRISE

Hi,
When trying to set up "Change Tracking" with "Update Index in Background"
the Enterprise Manager console freezes.
Do I need to stop some Windows services to do that ?
Configuration :
SQL Server 2000 + SP3
Windows 2000 + SP3
Any help will be appreciated.
Thanks.
This should not happen at all. What happens if you configure change tracking
with update index in background using TSQL.
Here is an example of how you would do this for the authors table:
exec sp_fulltext_table 'authors', 'start_change_tracking'
GO
exec sp_fulltext_table 'authors', 'start_background_updateindex'
GO
It is possible that you are experiencing some locking during the intial
population if you have a high number of inserts/updates/and deletes running.
Also are you running profiler? Profiler will degrade performance even while
you have paused the trace.
Hilary Cotter
Looking for a SQL Server replication book?
Now available for purchase at:
http://www.nwsu.com/0974973602.html
"Jean-Marc PUGIN" <jmpugin@.mobileworkers.com> wrote in message
news:euMN3dD3EHA.2804@.TK2MSFTNGP15.phx.gbl...
> Hi,
> When trying to set up "Change Tracking" with "Update Index in Background"
> the Enterprise Manager console freezes.
> Do I need to stop some Windows services to do that ?
> Configuration :
> SQL Server 2000 + SP3
> Windows 2000 + SP3
> Any help will be appreciated.
> Thanks.
>
|||Jean-Marc,
Most likely setting "Change Tracking" with "Update Index in Background" has
launched either an Incremental (if the table has a timestamp column) or a
Full Population in order to sync-up the MSSearch controlled FT Catalog with
the SQL Server 2000 table. Depending upon your server's resources this may
cause very high CPU-usage as well as with high memory and disk I/O to occur
during certain phases of the Incremental or Full Population and this will
have the affect of temporarily freezing the Enterprise Manager. Note, you
can use SQL Profiler or Perfmon or Task Mgr. to monitor the system usage.
Regards,
John
"Jean-Marc PUGIN" <jmpugin@.mobileworkers.com> wrote in message
news:euMN3dD3EHA.2804@.TK2MSFTNGP15.phx.gbl...
> Hi,
> When trying to set up "Change Tracking" with "Update Index in Background"
> the Enterprise Manager console freezes.
> Do I need to stop some Windows services to do that ?
> Configuration :
> SQL Server 2000 + SP3
> Windows 2000 + SP3
> Any help will be appreciated.
> Thanks.
>
|||John-
I have seen your name on quite a few posts and I believe you are helping
one of my colleagues on a FTS problem.
I thought I saw somewhere that you might have a list of Microsoft Full
Text Search replacements?
I am having a heck of a time finding something to replace the MS FTS in
SQL Server 2000. So far all I can find are web crawlers.
Could you give me some suggestions?
Thanks,
Dave
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
|||I'm sorry - hit submit by mistake.
I was actually going to offer some assistance on this question.
I did a small FTS build the other day, and I had the same problem. I
was using Query Analyzer, and it took 10 minutes for the second command
to complete execution (see previous posting).
If you do this in EM, expect the same behavior. It will appear to
freeze up for quite a while until it processes the commands.
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!