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

Monday, March 26, 2012

Having a hard time connecting to sample SQL database from ASP.Net Page

I am working through the book ASP.Net Unleashed Second Addition. I am trying to open a simple database connection. (using the sample "pubs" db from SQL Server)
I have copied the author's code exactly, but it just won't work. I keep getting this error:
What am I doing wrong???Confused [*-)]

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message:BC30182: Type expected.
Source Error:
Line 5: Line 6: Sub Page_LoadLine 7: Dim conPubs As SqlConnectionLine 8: conPubs = New SqlConnection( "server=localhost;uid=webuser;pwd=secret;database=pubs" )Line 9: conPubs.Open()
What namespaces have you imported?|||Coding for my namespace is
<%@. Import Namespace="System.Data.SqlClient" %>
This is copied directly from the authors example.... so I don't know if it is right lolWink [;)]
Then under the page_load event
I typed:
<script Runat="server">
Sub Page_Load
Dim conPubs as SqlConnection
conPubs = New SqlConnection( "Server=localhost;uid=sa;pwd=secret;database=pubs" )
conPubs. Open()
End Sub
</script>
The text "Connection Opened!" Is supposed to show up if the coding is correct...
Help hehe just a beginner :)|||Does anyone know some awesome websites that teach you Visual Studio.Net 2003 and database stuff? I have the hardest time finding things in the MSDN library....|||Try:
http://learnvisualstudio.net/|||

I don't know if VB.NEt support the continuation stuff.
If it does, may be u have to put a continuation sign at the end of line 7.
Cheers.

sql

Friday, March 23, 2012

Have Subreport NOT Keep Together

I have a subreport inside a table on the main report. It seems
everything I
try the subreport will keep together on a new page if it cannot fit
itself
on the rest of the first page. How can I have the subreport display
it's
data on the rest of the first page and continue on to the second page?
I have looked at everything I can think of. Keep Together is set to
false
everywhere.
Please help.
Thanks,Same thing here !
We have reports with 2-3 levels of subreports and the data "migrates"
sometimes to the 4th page, leaving the first 2-3 pages just with a small
header on top... it's very difficult to explain to a client why their report
looks like that. And this problem is active since the beginning of reporting
services. A few service packs later, a new version, and it's still out
there...
For some of the reports we managed to eliminate the subreports, but just
imagine how the datasets look like in the main report :(
Or, we transferred the burden of "subreporting" to the processing part,
creating a separate table to keep all the pre-calculated data, with headers
and subreport information, etc., leaving to Reporting Services the only task
of displaying the content of the table. But it's much more difficult and it
lacks flexibility !
Please, if anyone has a solution to this, make it public !
We regularly search the newsgroups for a solution to this problem, but
untill now, we just noticed a lot of people having this problem...
Thank you,
Andrei.
<sjackson@.nexterna.com> wrote in message
news:1168641290.758091.292180@.m58g2000cwm.googlegroups.com...
>I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||The sad thing is that I heard it is an issue that Microsoft has added
to their wish list. So you really need to limit the use of sub reports
or you can run into this issue.
Hopefully they can expedite the resolution of this issue.
Andrei wrote:
> Same thing here !
> We have reports with 2-3 levels of subreports and the data "migrates"
> sometimes to the 4th page, leaving the first 2-3 pages just with a small
> header on top... it's very difficult to explain to a client why their report
> looks like that. And this problem is active since the beginning of reporting
> services. A few service packs later, a new version, and it's still out
> there...
> For some of the reports we managed to eliminate the subreports, but just
> imagine how the datasets look like in the main report :(
> Or, we transferred the burden of "subreporting" to the processing part,
> creating a separate table to keep all the pre-calculated data, with headers
> and subreport information, etc., leaving to Reporting Services the only task
> of displaying the content of the table. But it's much more difficult and it
> lacks flexibility !
> Please, if anyone has a solution to this, make it public !
> We regularly search the newsgroups for a solution to this problem, but
> untill now, we just noticed a lot of people having this problem...
> Thank you,
> Andrei.
>
>
> <sjackson@.nexterna.com> wrote in message
> news:1168641290.758091.292180@.m58g2000cwm.googlegroups.com...
> >I have a subreport inside a table on the main report. It seems
> > everything I
> > try the subreport will keep together on a new page if it cannot fit
> > itself
> > on the rest of the first page. How can I have the subreport display
> > it's
> > data on the rest of the first page and continue on to the second page?
> >
> > I have looked at everything I can think of. Keep Together is set to
> > false
> > everywhere.
> >
> > Please help.
> >
> > Thanks,
> >|||Will someone from Microsoft please address this question? This is a very
basic reporting need. Is a service pack in the works?|||"sjackson@.nexterna.com" wrote:
> I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||I have the same problem.
I find many posts related to this problem and recentily I published my own
post with several links to other posts, but yet any answer from MS.
Here is my post
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1279676&SiteID=1
"sjackson@.nexterna.com" wrote:
> I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||Did anybody find a solution to this problem ?
Maybe somebody from Microsoft can be of assistance ?
<sjackson@.nexterna.com> wrote in message
news:1168641290.758091.292180@.m58g2000cwm.googlegroups.com...
>I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>|||Also wrestling with this one. Also irritated by the "No fields in headers or
footers thing" but got that working.
I am now at the point where I am possibly going to play with the byte stream
output by Localreport.Render("PDF"...) to try and make it work the way I
want. Fortunately only PDF is reuired.
Will come back to this post if I find something...
--
Programming is fun but paralgiding is better!|||Same thing here as well sjackson. No one has any answers? Let's add another
client to the 'I'm Not impressed with that SQL Reporting service thing mister
contractor' list.
"sjackson@.nexterna.com" wrote:
> I have a subreport inside a table on the main report. It seems
> everything I
> try the subreport will keep together on a new page if it cannot fit
> itself
> on the rest of the first page. How can I have the subreport display
> it's
> data on the rest of the first page and continue on to the second page?
> I have looked at everything I can think of. Keep Together is set to
> false
> everywhere.
> Please help.
> Thanks,
>

Have a problem with UpdateCommand

Hello everyone,

I am a bit new to ASP .Net so forgive me, if I dont understand something right off.

I am writing a page that gets code from the SQL database and puts it into a GridView. To get the information I am using SqlDataSource. I cant post an error message because I am running this off remote server but though testing I figure that it crashes when I add

Analysis = @.Analysis

line into the UpdateCommand. First I thought that maybe my parameters were not read correcty but when I tried something like

Analysis = 6

it worked. Then I tried to replace CQNo=@.CQNo with

CQNo = @.Analysis

and it also worked.

I am very much puzzed at this. In SQL database CQNo is varchar, WorkDate is DateTime and Analysis is Money type.

Can someone please help, I am out of ideas. Thanks!

<asp:SqlDataSourceID="myEfforts"runat="server"SelectCommand="SELECT SNo, CQNo, WorkDate, Analysis, Design, Coding, Testing, DesRev, CodeRev, PeerRev, SysTest, PostInstall, Others, TotEff FROM Effort WHERE EmpId = @.EmpId ORDER BY WorkDate DESC"DeleteCommand="DELETE FROM Effort WHERE SNo=@.SNo"UpdateCommand="UPDATE Effort SET CQNo = @.CQNo, WorkDate=@.WorkDate Analysis=@.Analysis WHERE SNo=@.SNo"><SelectParameters><asp:SessionParameterDefaultValue=""Name="EmpId"SessionField="PR_EmpIDVal"Type="String"/></SelectParameters>Looks like you are missing a comma after @.workdate and before Analysis? Or was that a type during pasting the code here?|||That was a typo when I was pasting the code in here. Sorry|||

I tried this and it works.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="SNo" DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="SNo" HeaderText="SNo" ReadOnly="True" SortExpression="SNo" />
<asp:BoundField DataField="CQNo" HeaderText="CQNo" SortExpression="CQNo" />
<asp:BoundField DataField="WorkDate" HeaderText="WorkDate" SortExpression="WorkDate" />
<asp:BoundField DataField="Analysis" HeaderText="Analysis" SortExpression="Analysis" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MSDN_forumConnectionString %>"
DeleteCommand="DELETE FROM [effort] WHERE [SNo] = @.SNo"
SelectCommand="SELECT [SNo], [CQNo], [WorkDate], [Analysis] FROM [effort]"
UpdateCommand="UPDATE [effort] SET [CQNo] = @.CQNo, [WorkDate] = @.WorkDate, [Analysis] = @.Analysis WHERE [SNo] = @.SNo">
<DeleteParameters>
<asp:Parameter Name="SNo" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CQNo" Type="String" />
<asp:Parameter Name="WorkDate" Type="DateTime" />
<asp:Parameter Name="Analysis" Type="Decimal" />
<asp:Parameter Name="SNo" Type="Int32" />
</UpdateParameters>

</asp:SqlDataSource>

|||Thanks a lot of taking the time, let me try this.|||

It worked! Thanks a lot!!!! Can you please explain what was causing the error (what I was doing wrong)?

Thanks a lot!

|||

I didn't see your whole page so my guess is the problem lies in the updateparameter part. A quick trick for this, you can always drag and drop a gridview to hook up with your table of interest in your database and ask for generating all commands (insert, update, delete). You will get a working copy to modify. Remeber assign a primary key for the table.

Glad you got it to work now.

Monday, March 19, 2012

Has anyone ever seen this fatal error?

We are getting the following error after execcuting an SP
on one of our clusters:
Server: Msg 7105, Level 22, State 6, Line 8
Page (1:16750), slot 4 for text, ntext, or image node does
not exist.
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
We are running SQL Server 2000 with SP3.
DBCC CHECKDB showed a problem with an index which we fixed
but the error still shows when we run the SP. DBCC
CHECKDB now shows no problems.
Is there any other way to track down this problem and/or
repair it?To resolve this problem, obtain the lates service pack for
Microsoft SQL Server 2000.
To work around the problem, either:
- Insert a dummy row in the table to import into so that
the table is not empty, and then delete the dummy row
after you import the data.
-or-
- Do not use the TABLOCK hint.
This posting is provided "AS IS" with no warranties, and
confers no rights.
http://www.microsoft.com/info/cpyright.htm
>--Original Message--
>We are getting the following error after execcuting an SP
>on one of our clusters:
>Server: Msg 7105, Level 22, State 6, Line 8
>Page (1:16750), slot 4 for text, ntext, or image node
does
>not exist.
>ODBC: Msg 0, Level 16, State 1
>Communication link failure
>Connection Broken
>We are running SQL Server 2000 with SP3.
>DBCC CHECKDB showed a problem with an index which we
fixed
>but the error still shows when we run the SP. DBCC
>CHECKDB now shows no problems.
>Is there any other way to track down this problem and/or
>repair it?
>
>.
>

Harish Mohanbabu

Hi,
How to create jobs in MS SQL Server 2000 for the following purposes -
1. For re-organise/re-index to 10% per page &
2. For checking DB integrity.
Can someone let me know please.
TIA,
Harish
*********************************
Long way to go before I sleep ..
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Hello Harish,
If you want the quick and dirty way use the maintenance wizard for this. If
you want scripts for this I can email some that I use.
Let me know if need to know how to run the maintenance wizard. Or just look
it up in the books online for SQL server, this is an excellent resource with
walk throughs and examples.
John...
"Harish Mohanbabu" <Harish@.nospam.com> wrote in message
news:eZ6VCrU$DHA.1732@.TK2MSFTNGP12.phx.gbl...
> Hi,
> How to create jobs in MS SQL Server 2000 for the following purposes -
> 1. For re-organise/re-index to 10% per page &
> 2. For checking DB integrity.
> Can someone let me know please.
> TIA,
> Harish
>
> *********************************
> Long way to go before I sleep ..
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!

Harish Mohanbabu

Hi,
How to create jobs in MS SQL Server 2000 for the following purposes -
1. For re-organise/re-index to 10% per page &
2. For checking DB integrity.
Can someone let me know please.
TIA,
Harish
*********************************
Long way to go before I sleep ..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Go to Enterprise Manager/management/database mainenance
plans. You can right click and select "new maintenance
plan", you just select the databases you want to setup and
it will walk you through the rest. You can also setup
full/tran log backups. You will then see the additions of
new jobs.
Hope that helps
thanks
Susan
>--Original Message--
>Hi,
>How to create jobs in MS SQL Server 2000 for the
following purposes -
>1. For re-organise/re-index to 10% per page &
>2. For checking DB integrity.
>Can someone let me know please.
>TIA,
>Harish
>
>*********************************
>Long way to go before I sleep ..
>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.
>|||Hello Harish,
If you want the quick and dirty way use the maintenance wizard for this. If
you want scripts for this I can email some that I use.
Let me know if need to know how to run the maintenance wizard. Or just look
it up in the books online for SQL server, this is an excellent resource with
walk throughs and examples.
John...
"Harish Mohanbabu" <Harish@.nospam.com> wrote in message
news:eZ6VCrU$DHA.1732@.TK2MSFTNGP12.phx.gbl...
> Hi,
> How to create jobs in MS SQL Server 2000 for the following purposes -
> 1. For re-organise/re-index to 10% per page &
> 2. For checking DB integrity.
> Can someone let me know please.
> TIA,
> Harish
>
> *********************************
> Long way to go before I sleep ..
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Monday, February 27, 2012

Handling world time with SQL and ASP.NET

Hi,

I would like to capture date time in my SQL during a certain operation. This piece of data will be displayed to an ASP.NET page.

When displaying the date time, I want it converted to the local time zone equivalent as set in the user's operating system.

What setup do I need on the SQL and the coding in the ASP.NET page?

Thanks.The following MSDN article may help you to understand date & time and also avoid inherant problems when dealing with different time zones.

Best Practices Using DateTime in the .NET

Hope this helps

Regards

Wayne Phipps|||Hi Wayne,

Thanks. That's a great article on issues related to saving and computing date time when daylight saving is relevant.

I'm also looking for saving date time in one time zone, and then display the date time relevant to the target user's system. I managed to find a web site that's dedicated to addressing this issue, SimpleTimeZone .NET Framework Class (http://www.michaelbrumm.com/simpletimezone.html). However I have not evaluated the .NET class concerned.

Thanks again for your reply.

Handling Errors...

Hello to all,

On my webPage I have Used one SQLDataSource to access DataBase. Now whenever some error occures it shows error page by default. I am not able to catch Errors and tackle in my way...

Furthermore in this new structure of accessing DataBase even I do not know where to write Try... Catch...

Hey mistry,
this is the structure for Try ... Catch ... in SQL

Begin Try
-- e.g.
INSERT INTO a SELECT * FROM b
-- your actual code
End Try
Begin Catch
-- code for error handling
End Catch

Sunday, February 19, 2012

Halloween Problem

Hi,
According to this page:
http://support.microsoft.com/kb/294860/EN-US
Halloween problem occurs where the physical location of a row within a table
changes due to a modification operation. As a result, the same row may be
revisited multiple times within the context of a single logical operation.
I found an example of Halloween problem in this page:
http://www.kbalertz.com/Feedback.aspx?kbNumber=285870
In this example, physical location of a row does not change during the
update operation. The "test" table has one index (clustered). The rows will
be moved only if the clustered key is updated (which does not occur here).
1) How does Halloween problem happen here?
2) Why Loop Join is not encountered with this problem?
Thanks in advance,
LeilaIs there a practical reason for this question, or is it an academic one? In
other words, do you have an update where you think you are seeing the
Halloween Problem?
The Halloween Problem is a classic database problem wherein the membership
in the set you are reading is changed by your own update operation, causing
you to see the same row repeatedly. The theoretical problem is independent
of the underlying rdbms implementation. The explanation in the first KB
article is incomplete in describing the problem. For example, even if rows
did not actually move a query plan that referenced any index incorporating a
column that is also being modified might be subject to the HP. In early
rdbms products it was up to the user to avoid making update requests that
would cause the Halloween Problem. In newer products, such as SQL Server
7.0/2000/2005 the Query Optimizer takes care of the problem via a technique
called Halloween Protection. When it sees that the update you are
performing could change one of the inputs it generates a plan that won't
have that problem. For example, it will spool the impacted inputs to a
temporary workfile before performing any updates and then read from the
temporary workfile rather than the underlying data that is being updated..
The second KB article is just pointing out a situation where the Query
Optimizer was not producing the correct plan. I didn't look at it in depth,
but I suspect that the reason Loop Join didn't have the problem is that the
optimizer was generating the correct Halloween Protection for that
situation.
--
Hal Berenson, President
PredictableIT, LLC
http://www.predictableit.com
"Leila" <Leilas@.hotpop.com> wrote in message
news:uIddyxRVGHA.4884@.TK2MSFTNGP10.phx.gbl...
> Hi,
> According to this page:
> http://support.microsoft.com/kb/294860/EN-US
> Halloween problem occurs where the physical location of a row within a
> table changes due to a modification operation. As a result, the same row
> may be revisited multiple times within the context of a single logical
> operation.
> I found an example of Halloween problem in this page:
> http://www.kbalertz.com/Feedback.aspx?kbNumber=285870
> In this example, physical location of a row does not change during the
> update operation. The "test" table has one index (clustered). The rows
> will be moved only if the clustered key is updated (which does not occur
> here).
> 1) How does Halloween problem happen here?
> 2) Why Loop Join is not encountered with this problem?
> Thanks in advance,
> Leila
>|||Thanks Hal,
Actually yes! This is an academic question which I'm interested(curious) in
its answer.
By your explanation I conclude that HP can occur when:
A) Rows are relocated (in index for example) and the update is using that
index
(http://blogs.msdn.com/ianjo/archive/2006/01/31/521078.aspx)
B) Update command accesses the rows that have been updated during itself
(which must be isolated)
According to KBs, HP is eliminated after installing SQL Server 2000 SP1. I
was trying this on a instance without SP.
The plan of update command in second KB which I mentioned is different from
instance with SP (This sample causes item B).
But what ever I tried to simulate HP by the cause of rows' relocation (item
A), the plan used a table spool which I think prevents HP (even no SP was
applied).
Do you have any sample that simulates that (Maybe my own experminet is
wrong)? or type A is always detected by the query optimizer and is prevented
even without SP?
I also include my code that used for testing item A:
--
use tempdb
go
drop table emp
go
create table emp(
eid int primary key,
salary int)
go
insert emp select 1,100
insert emp select 2,200
insert emp select 3,300
insert emp select 4,400
create index a on emp(salary)
-- Halloween=Yes, Solved by Table Spool
update emp
set salary=salary*1.1
from emp emp2 with(index(a))
where eid=emp2.eid
-- Halloween=No, Because index 'a' is not used
update emp
set salary=salary*1.1
from emp emp2
where eid=emp2.eid
-- Halloween=Yes, Solved by Sort
update emp
set eid=eid*1.1
--
Thanks,
Leila
"Hal Berenson" <hberenson@.predictableit.com> wrote in message
news:eIWuOTSVGHA.5652@.TK2MSFTNGP09.phx.gbl...
> Is there a practical reason for this question, or is it an academic one?
> In other words, do you have an update where you think you are seeing the
> Halloween Problem?
> The Halloween Problem is a classic database problem wherein the membership
> in the set you are reading is changed by your own update operation,
> causing you to see the same row repeatedly. The theoretical problem is
> independent of the underlying rdbms implementation. The explanation in
> the first KB article is incomplete in describing the problem. For
> example, even if rows did not actually move a query plan that referenced
> any index incorporating a column that is also being modified might be
> subject to the HP. In early rdbms products it was up to the user to avoid
> making update requests that would cause the Halloween Problem. In newer
> products, such as SQL Server 7.0/2000/2005 the Query Optimizer takes care
> of the problem via a technique called Halloween Protection. When it sees
> that the update you are performing could change one of the inputs it
> generates a plan that won't have that problem. For example, it will spool
> the impacted inputs to a temporary workfile before performing any updates
> and then read from the temporary workfile rather than the underlying data
> that is being updated..
> The second KB article is just pointing out a situation where the Query
> Optimizer was not producing the correct plan. I didn't look at it in
> depth, but I suspect that the reason Loop Join didn't have the problem is
> that the optimizer was generating the correct Halloween Protection for
> that situation.
> --
> Hal Berenson, President
> PredictableIT, LLC
> http://www.predictableit.com
>
> "Leila" <Leilas@.hotpop.com> wrote in message
> news:uIddyxRVGHA.4884@.TK2MSFTNGP10.phx.gbl...
>> Hi,
>> According to this page:
>> http://support.microsoft.com/kb/294860/EN-US
>> Halloween problem occurs where the physical location of a row within a
>> table changes due to a modification operation. As a result, the same row
>> may be revisited multiple times within the context of a single logical
>> operation.
>> I found an example of Halloween problem in this page:
>> http://www.kbalertz.com/Feedback.aspx?kbNumber=285870
>> In this example, physical location of a row does not change during the
>> update operation. The "test" table has one index (clustered). The rows
>> will be moved only if the clustered key is updated (which does not occur
>> here).
>> 1) How does Halloween problem happen here?
>> 2) Why Loop Join is not encountered with this problem?
>> Thanks in advance,
>> Leila
>