Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Wednesday, March 28, 2012

How to make sure no other table writes happen between 2 SQL statements ?

Ok, here is my situation....

When someone navigates to a user's profile page on my site, I present them with a slideshow of the user's photos using the AJAX slideshow extender. I obtain the querystring value in the URL (to determine which user's page I'm on) and feed that into a webservice via a context value where an array of photos is created for the slideshow. Now, in order to create the array's size, I do a COUNT of all of that specific user's photos. Then, I run another SQL statement to obtain the path of those photos in the file system. However, during the time of that first SQL query's execution (the COUNT statement) to the time of the second SQL query (getting the paths of the photos), the owner of that profile may upload or delete a photo from his profile. I understand this would be a very rare occurrence since SQL statements 1 and 2 will be executed within milliseconds of each other, but it is still possible I suppose. When this happens, when I try to populate the array, either the array will be too small or too large. I'm using SqlDataReader for this as it seems to be less memory and resource intensive than datasets, but I could be wrong since I'm a relative beginner and newbie.Wink This is what I have in my vb file for the webservice....

PublicFunction GetSlides(ByVal contextKeyAsString)As AjaxControlToolkit.Slide()
Dim dbConnectionAsNew SqlConnection("string for the data source, etc.")

Try
dbConnection.Open()

Dim memberId =CInt(contextKey)
Dim photoCountLookupCmdAsNew SqlCommand _
("SELECT COUNT(*) FROM Photo WHERE memberId = " & memberId, dbConnection)
Dim thisReaderAs SqlDataReader = photoCountLookupCmd.ExecuteReader()

Dim photoCountAsInteger
While (thisReader.Read())
photoCount = thisReader.GetInt32(0)
EndWhile
thisReader.Close()

Dim MySlides(photoCount - 1)As AjaxControlToolkit.Slide

Dim photoLookupCmdAsNew SqlCommand _
("SELECT fullPath FROM Photo WHERE memberId = " & memberId, dbConnection)
thisReader = photoLookupCmd.ExecuteReader()

Dim iAsInteger
For i = 0To 2
thisReader.Read()
Dim photoUrlAsString = thisReader.GetString(0)
MySlides(i) =New AjaxControlToolkit.Slide(photoUrl,"","")
Next i
thisReader.Close()

Return MySlides

Catch exAs SqlException

Finally
dbConnection.Close()

EndTry

EndFunction

I'm trying to use the most efficient method to interact with the database since I don't have unlimited hardware and there may be moderate traffic on the site. Is SqlDataReader the way to go or do I use something else? If I do use SqlDataReader, can someone show me how I can run those 2 SQL statements in best practice? Would I have to somehow lock writing to that table when I start the first SQL statement, then release the lock after I execute the second SQL statement? What's the best practice in this kind of scenario.

Thanks in advance.Smile

Hello S2KDriver,

Why don't you use a SqlDataAdapter and fill a DataTable with your second SELECT statement (e.g. the photoLookupCommand). You can use the rowcount property to get the number of rows retrieved.

In this scenario you still have the chance that when Slides are added to the AjaxControlToolkit, the photo is deleted and not available.

|||

Hi jeroenm,

Yes, now that I think about it, you're right. Since the photo's filepath is contained in the database and not the photo itself, there can be more or less photos by the time the aspx page receives the array of photo filepaths.

Maybe this is an ignorant and a beginner question, but if the dataset doesn't solve this problem of making sure things are in sync, what is its benefit over the datareader? The only time I've used the dataset is when implementing custom paging with datalists (since you can't page forwards AND backwards with a datareader). In all other instances, I've used the datareader and then I'd always make sure to close the reader right after each reading. I'm trying to be as stingy as possible in terms of resource utilization... is my approach wrong?

And also, to the issue at hand, I guess the only way to keep things in sync, is to somehow lock writing to the Photo table right before I execute my first SQL statement (to prevent the owner of the profile from uploading or deleting his photos during those few milliseconds), then release the write lock after I return the array of photo filepaths back to the requesting aspx page. Am I correct? And if so, how would I do this?

Thanks.

|||

The dataset was my suggestion to get ride of the first select statement. In your situation a datareader gives probably less resource utilization.

Maybe you can use the following scenario:

- open a transaction with the appropriate isolation level.

- update photo records with the matching memberid. (locking the set of records, you want to read locked).

- you will get the number of records updated by the command in return (given you the count).

- select the rows with the datareader and process the result set.

- rollback the transaction (releasing the lock).

I don't know when the AjaxControlToolkit reads the photo's. But if they are read just before showed to the user, you still have a synchronization issue.

How to make Sub total will be first the first record in next page

I have a report with 1 group per page.

I need Sub Total from Group footer in page 1 will be Subtotal in Group Header in Page 2 (or viewing in Group Header in Page 2), Sub Total from Group footer in page 2 will be Subtotal in Group Header in Page 3, and so on...

How to implement it...Plase help me, urgent.

Thanks Before,

AgusHave you tried to use shared variables?One way to solve the problem is to calculate running total in group footer and assign the value to shared variable.Then you could split group header where top section would display shared variable and bottom section would be used to reset it.|||Dear Denan,...

Thanks for your suggestion.
Actually i never used shared variabel. Would you like to help make an example formula code where is it using shared variabel.

Thanks before,

Agus|||Hi Agus
Well,as I said one formula should be placed in group header.Here you display your total and reset it.Formula would be something like this.
shared numbervar Total;//This is your shared variable
numbervar out;//temporary variable

out:=Total;//Assign total to temporary variable
Total:=0.0;//Reset Total
out//Display result

In group footer you calculate running total and assign that value to shared variable which will hold it until CR passes through group header next time

shared numbervar Total;//Shaerd variable must have same name as in header formula
Total:=#YourRunningTotalName

I hope this helps|||Thanks Denan,...

How to make more than One Page Report in Sql Server Reporting Services 2005

i have a stored procedure that return a single row and more than 100 colums data. i want to show that columns more than one page.

how can i design my report when i preview the report it shows the data on 2 page

DO you want to display the pages next to each other or do you want to display the second page under the first page ? For the first one simply extend the page size to the double size. For the second choice place multiple detail rows on the page until all data is displayed.

HTH, Jens SUessmeyer.

http://www.sqlserver2005.de

Monday, March 26, 2012

How to make footers page number appear when i print the report

I have the footer with the following in it,

**********************************

= " Page " & Globals!PageNumber & " of " & Globals!TotalPages & " " & String.Format(Globals!ExecutionTime, "dd-MM-yyy uu:mm")

********************************

When i view the report it shows the page number and time, but when i print it does'nt appear at all on the print paper( page number and time)

is there a trick to make it appear on the print.

Thank you very much.

Reddy,

I'm going to assume you have the above code inside a textbox expression with in your footer. There is no smoke and mirror involved in displaying page number in the footer. I would suggest checking the textbox to make sure visible is true, check footer for printonfirstpage is true (in case there's one page), also go to the print view of the report to see if it shows up there.

I hope this helps.

Ham

|||You might have it too far down. Sometimes it cuts it off if you place the textbox too far down.

Friday, March 23, 2012

How to make a page break...correctly

I am creating a report that uses a list control and have the break at end of
list. This does not work on all pages. I have some sections that spill over
to another page. This would not be a problem if the list control would insert
a page break prior to starting the next section. Also, it seems that some
reports that are shorter, the next section starts on the same page. Is there
some trick to making a report insert a page break where you want it to
everytime? I am using SSRS 1 w/SP2.On Mar 1, 7:06 am, Wannabe <Wann...@.discussions.microsoft.com> wrote:
> I am creating a report that uses a list control and have the break at end of
> list. This does not work on all pages. I have some sections that spill over
> to another page. This would not be a problem if the list control would insert
> a page break prior to starting the next section. Also, it seems that some
> reports that are shorter, the next section starts on the same page. Is there
> some trick to making a report insert a page break where you want it to
> everytime? I am using SSRS 1 w/SP2.
I have not used SP2 yet; however, prior to that, if you right click
the list control and go to Properties on the General tab below Page
Breaks you should be able to select 'Insert a page break after this
list.' Also, if you are using a table inside the list you should be
able to insert a page break after the table; as well, as after any
groups defined in the table. That said, sometimes the grouping in SSRS
is a little funny when it comes to lists and tables. Hope this is
helpful.
Regards,
Enrique Martinez
Sr. SQL Server Developer|||On the list control, I do have the property checked to break after the list.
Just it does not always seem to work. I have one list control in the body of
the page. In this list control, I have many textbox controls. The list
control is tied to a datasource and I have ten records in this datasource, so
I expect 10 pages from my report. But what happens, is that records one and
two will display on a page by themselves, but record three will have part of
record four at the bottom of it, then record four finishes, and record five
will be back to a page of its own. This happens every so often and I do not
see a pattern. Hope this makes sense. Thanks for looking into this.
"EMartinez" wrote:
> On Mar 1, 7:06 am, Wannabe <Wann...@.discussions.microsoft.com> wrote:
> > I am creating a report that uses a list control and have the break at end of
> > list. This does not work on all pages. I have some sections that spill over
> > to another page. This would not be a problem if the list control would insert
> > a page break prior to starting the next section. Also, it seems that some
> > reports that are shorter, the next section starts on the same page. Is there
> > some trick to making a report insert a page break where you want it to
> > everytime? I am using SSRS 1 w/SP2.
>
> I have not used SP2 yet; however, prior to that, if you right click
> the list control and go to Properties on the General tab below Page
> Breaks you should be able to select 'Insert a page break after this
> list.' Also, if you are using a table inside the list you should be
> able to insert a page break after the table; as well, as after any
> groups defined in the table. That said, sometimes the grouping in SSRS
> is a little funny when it comes to lists and tables. Hope this is
> helpful.
> Regards,
> Enrique Martinez
> Sr. SQL Server Developer
>|||On Mar 1, 9:01 am, Wannabe <Wann...@.discussions.microsoft.com> wrote:
> On the list control, I do have the property checked to break after the list.
> Just it does not always seem to work. I have one list control in the body of
> the page. In this list control, I have many textbox controls. The list
> control is tied to a datasource and I have ten records in this datasource, so
> I expect 10 pages from my report. But what happens, is that records one and
> two will display on a page by themselves, but record three will have part of
> record four at the bottom of it, then record four finishes, and record five
> will be back to a page of its own. This happens every so often and I do not
> see a pattern. Hope this makes sense. Thanks for looking into this.
> "EMartinez" wrote:
> > On Mar 1, 7:06 am, Wannabe <Wann...@.discussions.microsoft.com> wrote:
> > > I am creating a report that uses a list control and have the break at end of
> > > list. This does not work on all pages. I have some sections that spill over
> > > to another page. This would not be a problem if the list control would insert
> > > a page break prior to starting the next section. Also, it seems that some
> > > reports that are shorter, the next section starts on the same page. Is there
> > > some trick to making a report insert a page break where you want it to
> > > everytime? I am using SSRS 1 w/SP2.
> > I have not used SP2 yet; however, prior to that, if you right click
> > the list control and go to Properties on the General tab below Page
> > Breaks you should be able to select 'Insert a page break after this
> > list.' Also, if you are using a table inside the list you should be
> > able to insert a page break after the table; as well, as after any
> > groups defined in the table. That said, sometimes the grouping in SSRS
> > is a little funny when it comes to lists and tables. Hope this is
> > helpful.
> > Regards,
> > Enrique Martinez
> > Sr. SQL Server Developer
Unfortunately, SSRS is a bit flaky sometimes when it comes to grouping
and page breaks. The only other thing I can think of is to try to put
the textbox controls inside a rectangle and then inside a list
control.
Regards,
Enrique Martinez
Sr. SQL Server Developer

How to make a page break so table details are not split to 2 pages

How to make a page break so table details are not split to 2 pages?
I use table to show details for each record (Each record has several table
rows). One page can have several records. But if the blank is not enough for
one record, I want that record to be on the next page.
How can I achieve this?
I have chosen the page detail "keeptogether" as TRUE.I have solved this problem by using table details grouping property.
"Hello Kitty" wrote:
> How to make a page break so table details are not split to 2 pages?
> I use table to show details for each record (Each record has several table
> rows). One page can have several records. But if the blank is not enough for
> one record, I want that record to be on the next page.
> How can I achieve this?
> I have chosen the page detail "keeptogether" as TRUE.|||HK... if you don't mind my asking... how did u fix your problem exactly...
the details grouping allows you to force a page break after or before the
grouping... but if you do that... sure you won't have any records broken
up... but don't you end up with each record on a new page?
"Hello Kitty" wrote:
> I have solved this problem by using table details grouping property.
> "Hello Kitty" wrote:
> > How to make a page break so table details are not split to 2 pages?
> >
> > I use table to show details for each record (Each record has several table
> > rows). One page can have several records. But if the blank is not enough for
> > one record, I want that record to be on the next page.
> > How can I achieve this?
> >
> > I have chosen the page detail "keeptogether" as TRUE.

Monday, March 19, 2012

How to load any file into FTP server through Javascript.

Dear all,
Iam with a small problem.
I want to access to FTP server through Html page by entering a username
and password.In the same html page I have to slect a file through
browse button and load it into FTP server.
PLz help me with the code also.
All this should be in Javascript.
Any help is appreciated...
Thanks a lot...~!~!~!
Bye
Hi
If this is ASP then you can use one of the products mentioned on
http://www.aspfaq.com/show.asp?id=2189.
This is not really an XML or SQL Server question so posting in a more
appropriate group may be an idea!
John
"vinodh" <vinodh.singh@.gmail.com> wrote in message
news:1126834578.588797.184610@.f14g2000cwb.googlegr oups.com...
> Dear all,
>
> Iam with a small problem.
> I want to access to FTP server through Html page by entering a username
> and password.In the same html page I have to slect a file through
> browse button and load it into FTP server.
> PLz help me with the code also.
> All this should be in Javascript.
> Any help is appreciated...
>
> Thanks a lot...~!~!~!
> Bye
>

How to load any file into FTP server through Javascript.

Dear all,
Iam with a small problem.
I want to access to FTP server through Html page by entering a username
and password.In the same html page I have to slect a file through
browse button and load it into FTP server.
PLz help me with the code also.
All this should be in Javascript.
Any help is appreciated...
Thanks a lot...~!~!~!
ByeHi
If this is ASP then you can use one of the products mentioned on
http://www.aspfaq.com/show.asp?id=2189.
This is not really an XML or SQL Server question so posting in a more
appropriate group may be an idea!
John
"vinodh" <vinodh.singh@.gmail.com> wrote in message
news:1126834578.588797.184610@.f14g2000cwb.googlegroups.com...
> Dear all,
>
> Iam with a small problem.
> I want to access to FTP server through Html page by entering a username
> and password.In the same html page I have to slect a file through
> browse button and load it into FTP server.
> PLz help me with the code also.
> All this should be in Javascript.
> Any help is appreciated...
>
> Thanks a lot...~!~!~!
> Bye
>

Friday, March 9, 2012

How to Limit the number of columns in the Matrix ?

HI all !

I am having a bit of a problem trying to limit a number of columns in a matrix appearing on a page.

At the moment, I have a dataset that lists the month and the mail packages that were sent during the month
The matrix works great HOWEVER, if there were more than 8 months in the matrix columns, it does not break and would make the page look like a huge landscape page.

I am trying to limit the number of columns appearing (this is the months column) on the matrix so that the pages stay in a potrait position. IE: every 8 columns appear on one page. Is there an option or an expression I could use in the Matrix ?
Thanks!

BErnard Ong

An update on this situation.

After figuring what keywords to use, I think I might have found the answer to this dilemma.

This is the post that might be useful to anyone who might want to wrap the number of columns in the matrix so that it will print a new page !

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=934445&SiteID=1

Can anyone suggest what would be a better way to title my thread so that other users can find this easily if they have this problem ? never thought of using the wrap keyword, and I actually had to find this thread by using "Columns in Matrix" and searching through a couple of pages.

Thanks !

Bernard Ong

how to limit number of rows showing each page?

Hi All,

i couldn't find how to set up the number of rows displaying on each page?

i wanna each page display 20 rows.

Thanks

Nick

There's no explicit way of doing it, but it can be achieved by placing your table inside a list control then add a grouping with the folowing expression:

= Ceiling(RowNumber(Nothing)/20)

Make sure you check the page break at end option.

|||

Cool..

I got it.. thank you very much,, Adam

How to limit number of rows displayed in a report from a report designer

How to limit number of rows displayed in a report, i' am using report project in Visual studio 2005 to design my reports

How to use page navigation once i deploy the report on to report server..?

Hello Kkreddy:

I have searched it for you.

I am sorry I have not found a good answer for you.

Your problem seems to be a pure report server problem.

I will move your thread to the report server forum.

I believe you can get a more rapid and precise answer there.

Thank you very much.

How to limit number of rows displayed in a report from a report designer

How to limit number of rows displayed in a report, i' am using report project in Visual studio 2005 to design my reports

How to use page navigation once i deploy the report on to report server..?

Hello Kkreddy:

I have searched it for you.

I am sorry I have not found a good answer for you.

Your problem seems to be a pure report server problem.

I will move your thread to the report server forum.

I believe you can get a more rapid and precise answer there.

Thank you very much.