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

Friday, March 30, 2012

problems with two insert queries in a page

Hello

I have a question about something odd happening with an insert query.

I am working on a password protected site and I want to moniter general student use. I have an on page load even which picks up their user id and the url and sends it to the database

Because my site is a beta site, I also want the users to be able to add their comments as and when they want, so I built a small feedback form on each page.

The quick feedback form has a panel to hide it until a user clicks on a radio button and this reveals a text box and a submit button.

However, since I have added this second sql connection with an insert, I now get an error message I was getting a connection string error when I tried to point at the connection string in the web.config file, so I put the full path in to the database and now I get an error message that says the conTrackUser has not been declared, but as you can see from the code it certainly has. So I'm beginning to thing that the error is something entierly different, but that's probably me being thick.

I've pasted the two insert blocks below, I can't see anything wrong with them, but then I'm mostly groping about in the dark with asp.net.

Is it not possible to have two insert commands on a page? That would be daft.

Here is the code.

Track and initilize the radio button and panel for the feedback:


Sub Page_Load(Sender As Object, E As EventArgs)
Dim UserID as String = session("UserID")
pnlQuickFeedback.Visible = False
If Not Page.IsPostback Then
Dim conTrackUser As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand

conTrackUser = New SqlConnection("server='server'; user id='me'; password='nuts'; database='database'")

cmdInsert = New SqlCommand("TrackUser5530", conTrackUser)
cmdInsert.CommandType = CommandType.StoredProcedure
cmdInsert.Parameters.Add("@.UserIdentity", session("UserID") )
cmdInsert.Parameters.Add("@.URL", Request.Url.AbsoluteUri )

conTrackUser.Open()
cmdInsert.ExecuteNonQuery()
conTrackUser.Close()
End If
End Sub


The sub for the feedback:

Sub SubmitFbbtn_Click(Sender As Object, E As EventArgs)
Dim UserID as String = session("UserID")

'If Not Page.IsPostback Then
Dim conQuickFeedback As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand

conQuickFeedback = New SqlConnection("server='server'; user id='me'; password='nuts'; database='database'")

cmdInsert = New SqlCommand("QuickComments5530", conQuickFeedback)
cmdInsert.CommandType = CommandType.StoredProcedure
cmdInsert.Parameters.Add("@.UserIdentity", session("UserID") )
cmdInsert.Parameters.Add("@.Comments", txtComments.text)
cmdInsert.Parameters.Add("@.URL", Request.Url.AbsoluteUri )

conQuickFeedback.Open()
cmdInsert.ExecuteNonQuery()
conQuickFeedback.Close()
pnlQuickFeedback.Visible = False
feedbackFormbtn.Visible = True
feedbackFormbtn.Checked = False
End Sub


thanksTry using

data source='server'; user id='me'; password='nuts'; initial catalog='database'

Problems with text column in SQL SERVER 2000

Hi,
I am trying to access the data inside a text column in the database and display it on a page.
The problem is, I cannot see the full data when I execute the stored procedure in SQL Server and also on the asp.net page.
it seems Sql server clips the data if it is more than 3000 characters. Is there anyway I can see the whole data that is stored in that particular column.
I do not understand why asp.net is also clipping the data. What container can I use to display the text? I have tried Literal, string, placeholder but nothing shows the full text that is supposed to be in the database.
I have seen some people using byte arrays but I am not sure how I can use them to display data on a page.
If anyone has done this before or had a similar problem please reply back.
Thanks.

Are you sure it is with the page and not the size of the parameters or the size of the field. my guess is that one of those are varchar(3000)

|||

To add to the previous post Char is fixed length, while Varchar is variable length so, I would change to Char if it is Varchar 3000. Byte arrays is for Binary data in SQL Server. Hope this helps.

|||The data type of the column is text and its length shows as 16. As far as I know, a text column can take any length of text. But I am not sure why it's not inserting the whole text and clipping it after certain characters.
I think now it's something on the database side, not on the asp.net page.
Any ideas why Sql Server is not inserting the whole data?
I tried retrieving the results to a text file and tried to see if it displays the whole text. But it shows only a small chunk of the data.
I am not sure what's wrong.|||What type of structure are retrieving the data into within your asp.net app? DataSet? Custom object? If you are using dataadapters to load your data into a dataset I would take a look at the length of the parameter representing this text field within your dataadapter commands.
Oscar|||Text datatype can grow to 2gig in size and is usually not table space based which means it is not for data stored in a column. SQL Server creates an Arithmetic pointer to the data in your file system. If you know your data from Asp.net is ASCII you can use Varchar 4000 and Char 4000, if it is Unicode you can use Nvarchar 2000 and Nchar 2000. The other option is use image which can also grow to 2gig and store the data in Word. Hope this helps.|||

I am having the same problem. It is not caused by varchar(3000) or anything else. I have change the field from text to varchar(7900) and still have the problem.
I am loading the data into a dataset variable. When you look at the dataset's tables(0).rows(0).item("field_name"), it has length 3000.
Any one else have any thoughts?

|||

orderdog,
if your loading data into a dataset where the length of the fiedl is defined as 3000, then that is all the data your going to get in or out of your dataset once loaded. Typically, if you create a dataadapter using a table from your database your text columns will be automatically converted to varchar with a size of 2million and some odd characters.
oscar

Wednesday, March 28, 2012

Problems with Subreports when no data is returned & page breaks ar

I've been fighting a problem in SQL Reporting Services 2005 and am about to
go nuts! I have a main report that contains multiple subreports. Each
subreport is contained within its own List (I've tried Tables too), tied to
the DataSet specific to each subreport. Each subreport may or may not return
data, based on the DataSet of the List/Table.
My problem occurs when one or all of the subreports do not return data. The
users would like each subreport to start on a new page, which I thought
should be simply handled by setting the Page Break at Start property of the
List/Table's Grouping. This does in fact work as desired, but only when ALL
subreports return data. When one (or more) of the subreports is blank, an
extra page is rendered, which when paged to causes an error (An error
occurred during local report processing. An internal error occurred on the
report server. See the error log for more details.) I've been able to find
nothing in any error log, which is what the BOL says for this error (in
addition to telling you that this error should never occcur!).
Can someone please help!? I have a deadline to meet!
Thanks in advance.Hi Jeff,
I am stuck with the same problem and have been recommended to use the NoRows
property. However this does unfortunately not help. The problem seems to
arise as soon as something re-renders the page. In my case a drill-down
re-renders the page and causes this error if I have an empty sub-report on
the page.
If you have found a work-around I would be glad if you could post it.
"Jeff Rautzahn" wrote:
> I've been fighting a problem in SQL Reporting Services 2005 and am about to
> go nuts! I have a main report that contains multiple subreports. Each
> subreport is contained within its own List (I've tried Tables too), tied to
> the DataSet specific to each subreport. Each subreport may or may not return
> data, based on the DataSet of the List/Table.
> My problem occurs when one or all of the subreports do not return data. The
> users would like each subreport to start on a new page, which I thought
> should be simply handled by setting the Page Break at Start property of the
> List/Table's Grouping. This does in fact work as desired, but only when ALL
> subreports return data. When one (or more) of the subreports is blank, an
> extra page is rendered, which when paged to causes an error (An error
> occurred during local report processing. An internal error occurred on the
> report server. See the error log for more details.) I've been able to find
> nothing in any error log, which is what the BOL says for this error (in
> addition to telling you that this error should never occcur!).
> Can someone please help!? I have a deadline to meet!
> Thanks in advance.

problems with SQL Server cache invalidation

Hi I am using SQL Server cache invalidation with caching in my application.

I have a master page and several other pages that are referring the master page.

I have specified :

<%@.OutputCacheDuration="60"VaryByParam="*"SqlDependency="CommandNotification" %> on one of my content page.

and I have included the

System.Data.SqlClient.SqlDependency.Start(connectionstring) in my Application_Start.

My web.config contains this section as well -

<caching>

<sqlCacheDependencyenabled="true">

<databases>

<addname="BizPartnerV4"connectionStringName="BizPartnerConnectionString"/>

<addname="DirectBuyBeaverton"connectionStringName="DirectBuyBeavertonConnectionString"/>

</databases>

</sqlCacheDependency>

I</caching>

have also run the aspnet_regsql utility to enable sqlcache dependency for the database.

But my page is not taking the values from cache when the page is refreshed.

Please help.

Hi,

you have two options to work with SQLServer cache:

1.push from the SQL Server

2.polling from Web server

Check your configuration to see if it si configured the right way.

|||

What are you using for the database? SQL Server 2005, SQL Express, or SQL Server 2000?

|||

I am using SQL Server 2005.

I guess it is using the push model

|||

Change VaryByParam from * to None, and see if it is now caching.

|||

no it still doesn't cache

|||

If you use implement cache with SQLServer 2005 , try the following steps:

1) Enable notifications for the database using the aspnet_regsql.exe tool. >aspnet_regsql.exe -S ".\SQLExpress" -E -d "pubs" -ed
This only needs to be done once for each database.


2) Enable notifications for the table(s) you want to have dependencies on using the aspnet_regsql.exe tool. >aspnet_regsql.exe -S ".\SQLExpress" -E -d "pubs" -et -t "authors"
3) Register the notification in the configuration for the application. <system.web>
<caching>
<sqlCacheDependency enabled="true" pollTime="1000" >
<databases>
<add name="PubsDB" connectionStringName="Pubs" />
</databases>
</sqlCacheDependency>
</caching>
</system.web>The poll time specifies how often the application checks to see whether the data has changed.


4) A SQL dependency can then be used on the OutputCache directive: <%@. OutputCache Duration="999999" SqlDependency="Pubs:Authors" VaryByParam="none" %>Or it can be specified directly on a datasource control: <asp:SqlDataSource EnableCaching="true" CacheDuration="Infinite" SqlCacheDependency="PubsDB:Authors" ... />

Hope this helps.

Thanks.

Friday, March 23, 2012

Problems with report fitting to a page when exporting and then printing from Excel

I have various reports in both portrait and landscape and when I export to Excel although the page orientation works correctly the report does not print correctly in that the right hand side of the report gets chopped.

In the report definition I have all the margins set to 0.5cm and the page height set to 29.7cm and the width to 21cm for portrait and the other way around for landscape. In designing my report I have a report width 1cm less to take account of the margins i.e. 28.7 for a landscape report and 20cm for a portrait report. The report is defined in all this space as I have lines in my header and footer than span the whole report width.

If I am doing my calculations above correctly I cannot see why the report does not fit to a page when exporting to Excel. Printing directly from the browser or PDF works fine.

Thanks in advance for any help.

Excel has its own print mechanism. Do a print preview of the report in Excel before printing.

My guess would be that Excel is adding its own margins.

|||

The print margins in Excel are exactly the same as I defined in the report 0.5cm on all sides so that does not look like Excel is having any problems getting the margin information.

|||

Yes, you can call a com object from Microsoft.Office.Interop.Excel and redesign the workbook the example code is here:

yo need the file in Excel (*.xls) this is the "FinalFileName"

Imports:
Excel = Microsoft.Office.Interop.Excel

Code:

Dim app As New Excel.Application
Dim wb As Excel.Workbook
Dim fs As System.IO.FileStream
Dim writer As System.IO.BinaryWriter
fs = New System.IO.FileStream(FinalFileName, System.IO.FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
Dim writer As System.IO.BinaryWriter
fs.Close()
fs.Dispose()
app.DisplayAlerts = False
wb = appp.Workbooks.Open(Finalfile)
With CType(wb.Worksheets(1), Excel.Worksheet).PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.CenterHorizontally = True
.CenterVertically = True
.Draft = False
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
wb.PrintOut()
wb.Unprotect()
appp.Workbooks.Close()
appp.Quit()
fs.Close()
fs.Dispose()

Problems with report fitting to a page when exporting and then printing from Excel

I have various reports in both portrait and landscape and when I export to Excel although the page orientation works correctly the report does not print correctly in that the right hand side of the report gets chopped.

In the report definition I have all the margins set to 0.5cm and the page height set to 29.7cm and the width to 21cm for portrait and the other way around for landscape. In designing my report I have a report width 1cm less to take account of the margins i.e. 28.7 for a landscape report and 20cm for a portrait report. The report is defined in all this space as I have lines in my header and footer than span the whole report width.

If I am doing my calculations above correctly I cannot see why the report does not fit to a page when exporting to Excel. Printing directly from the browser or PDF works fine.

Thanks in advance for any help.

Excel has its own print mechanism. Do a print preview of the report in Excel before printing.

My guess would be that Excel is adding its own margins.

|||

The print margins in Excel are exactly the same as I defined in the report 0.5cm on all sides so that does not look like Excel is having any problems getting the margin information.

|||

Yes, you can call a com object from Microsoft.Office.Interop.Excel and redesign the workbook the example code is here:

yo need the file in Excel (*.xls) this is the "FinalFileName"

Imports:
Excel = Microsoft.Office.Interop.Excel

Code:

Dim app As New Excel.Application
Dim wb As Excel.Workbook
Dim fs As System.IO.FileStream
Dim writer As System.IO.BinaryWriter
fs = New System.IO.FileStream(FinalFileName, System.IO.FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
Dim writer As System.IO.BinaryWriter
fs.Close()
fs.Dispose()
app.DisplayAlerts = False
wb = appp.Workbooks.Open(Finalfile)
With CType(wb.Worksheets(1), Excel.Worksheet).PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.CenterHorizontally = True
.CenterVertically = True
.Draft = False
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
wb.PrintOut()
wb.Unprotect()
appp.Workbooks.Close()
appp.Quit()
fs.Close()
fs.Dispose()

sql

Problems with Printing and rendering to PDF

Hi,

I have an SQL server 2000 and I am creating a simple 1 page report using the Reporting Services and Visual Studio 2003. Everything is working fine. When I on "Preview" or when I access the report using a URL to disply it in HTML, I get a perfect report.

However, when I click on the "Print Preview" Icon (in the Preview Tab), or when I Render it as PDF, something goes wrong and it divides the report in 2 pages. On the first, there is only the company logo and the outlines of the tables used, while the rest of the report (minus the logo) is on the second page! I tried removing the logo, but still got a first page with only the outlines of tables. I also tried increasing the margins, with no success! I even tried removing some of the tables from the report, and test it, also the same result! could it be the datasets?

Did anybody get this problem? What could possibly be the reason?

Thanks a lot

Bob

Yes, the only way that I was able to stop this from happening was to reduce the margin size in the report properties.|||

Thx

yes it was the margins of the report that did this, especially the left and right margins.

sql

Problems with Printing and rendering to PDF

Hi,

I have an SQL server 2000 and I am creating a simple 1 page report using the Reporting Services and Visual Studio 2003. Everything is working fine. When I on "Preview" or when I access the report using a URL to disply it in HTML, I get a perfect report.

However, when I click on the "Print Preview" Icon (in the Preview Tab), or when I Render it as PDF, something goes wrong and it divides the report in 2 pages. On the first, there is only the company logo and the outlines of the tables used, while the rest of the report (minus the logo) is on the second page! I tried removing the logo, but still got a first page with only the outlines of tables. I also tried increasing the margins, with no success! I even tried removing some of the tables from the report, and test it, also the same result! could it be the datasets?

Did anybody get this problem? What could possibly be the reason?

Thanks a lot

Bob

Yes, the only way that I was able to stop this from happening was to reduce the margin size in the report properties.|||

Thx

yes it was the margins of the report that did this, especially the left and right margins.