Showing posts with label net. Show all posts
Showing posts with label net. Show all posts

Tuesday, March 27, 2012

Ho do I allow multiple users to share a SQL 2005 Express database?

Hello,

Ho do I allow multiple users to share a database?

Background

I have developed a Windows App in VS.NET 2005 which connects to a SQL 2005 Express database.

Now I want to install the app and database on the network and I am getting an error "File 'file_name' is on a network device not supported for database files"

What is the best way to get this working

Thanks in advance,

Phil

Sorry, please find my connection string below. (Note that Z:\ is my network share)

Data Source=.\SQLEXPRESS;AttachDbFilename="Z:\Data\SurveyDB.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True

Thanks,

Phil

|||do you really need it as user instance, i suggest that you attach the database to the main instance of sqlexpress and modify your connection string. user instance bahaves differently since everytime an applicaqtion is calling this method, the calling application spawns a service to the installed sql server express and makes the user of the calling application its administrator|||

Hi, and thanks for your prompt reply,

It seems that I am only just learning about the different types of connections!

How do I attach the database to the main instance of SQL Express? And then what would an example of my connection string be?

Thanks

Phil

|||

OK, I somehow have made a "main instance" of the database, and have changed my connection string to Server=LAPTOP\SQLEXPRESS;Database=SurveySystemsDB;Trusted_Connection=True

BUT I have no idea on how I "converted" my database from its original "User Instance" to the "main instance"

Can anybody tell me how to do this?

Thanks,

Phil

|||

Hi Phil,

User Instances are not about the database, it's about the server itself. A User Instance is a special instance of SQL Express that is started up at run-time; you can read about the details in the User Instance white paper. You can not actually share a User Instance between multiple users, they are designed to only allow local access.

The way you "converted" your database is simply by attaching it to your main instances of SQL Express rather than trying to attach it at run time using a connection string. Since I wasn't there when you attached your file, I couldn't tell you how you did it. The normal ways of attaching a database are to run T-SQL script, such as using sp_attach_db or by using a GUI tool such as Management Studio Express to attach the database.

Once a database is attached to a server, you appliction simply makes a connection as you've demonstrated above.

Regards,

Mike Wachal
SQL Express team

-
Check out my tips for getting your answer faster and how to ask a good question: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=307712&SiteID=1

sql

Monday, March 26, 2012

Hindi fonts

Hello all

Using hindi fonts in the asp.net, is that possible...

admin area adding a new data in the database and when the save and all value save on the database

HINDI FONTS Using in backends.......................

Hi,

Check this article : http://www.codeproject.com/useritems/localization.asp

Hope this helps,

Vivek

Friday, March 23, 2012

Highlight Keywords

I am using asp.net (C#) to create full text searching using SQL Server
2005 in our application. Everything is working fine, but I am trying
to highlight the resultset keywords from the full text results. Can
sql server provide you with a way to highlight the keywords from the
full text search?
I was able to kind of hack it by programatically replacing my keyword
search terms with the sql server resultset. However, when I do certain
searches, like "Frank's", sql server will return Frank using my
CONTAINS query, and I want the other results like "Frank" to be
highlighted too. Anyone know a good way to go about doing this?
Thanks
You have to implement your own version of Porter stemmer algorithm for this.
You can use Indexing Services for this, here is a link describing how to do
this.
http://www.indexserverfaq.com/sqlhithighlighting.htm
"guate911" <guatemala911@.gmail.com> wrote in message
news:1179417689.771131.84700@.k79g2000hse.googlegro ups.com...
>I am using asp.net (C#) to create full text searching using SQL Server
> 2005 in our application. Everything is working fine, but I am trying
> to highlight the resultset keywords from the full text results. Can
> sql server provide you with a way to highlight the keywords from the
> full text search?
> I was able to kind of hack it by programatically replacing my keyword
> search terms with the sql server resultset. However, when I do certain
> searches, like "Frank's", sql server will return Frank using my
> CONTAINS query, and I want the other results like "Frank" to be
> highlighted too. Anyone know a good way to go about doing this?
> Thanks
>

High Volume of Net Traffic coming from MSSQL

We're having a bit of an issue with network traffic being generated from one
of our MSSQL Servers.
It seems that when we launch Enterprise Manager on a remote computer
(usually at another office), the MSSQL servers start sending packets to the
EM regardless of whether we are maintaining an active connection to the
server or not. What is happening is that these packets are being lost and
reported in our firewall as 'host unreachable'. These packets are also
firing every second for each EM open across our network, so this is becoming
a bit of a pain for our poor network guys. The other odd thing is that the
firewall is only reporting one-way traffic, from the server to the client,
but the client is not sending any traffic back down unless it is actively
connected to the remote server.
Any thoughts as to why this might be happening, or better yet, a way to cull
this traffic?
We're running MSSQL 2000 SP3a on Windows 2003 servers.
Thanks in advance!
Mike,Have you applied the post-SP3a hotfix?
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
We're having a bit of an issue with network traffic being generated from one
of our MSSQL Servers.
It seems that when we launch Enterprise Manager on a remote computer
(usually at another office), the MSSQL servers start sending packets to the
EM regardless of whether we are maintaining an active connection to the
server or not. What is happening is that these packets are being lost and
reported in our firewall as 'host unreachable'. These packets are also
firing every second for each EM open across our network, so this is becoming
a bit of a pain for our poor network guys. The other odd thing is that the
firewall is only reporting one-way traffic, from the server to the client,
but the client is not sending any traffic back down unless it is actively
connected to the remote server.
Any thoughts as to why this might be happening, or better yet, a way to cull
this traffic?
We're running MSSQL 2000 SP3a on Windows 2003 servers.
Thanks in advance!
Mike,|||We have the entire SP3a hotfix installed, but I am unaware of a post SP3a fix
- are you referring to SP4?
"Tom Moreau" wrote:
> Have you applied the post-SP3a hotfix?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> ..
> "Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
> news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
> We're having a bit of an issue with network traffic being generated from one
> of our MSSQL Servers.
> It seems that when we launch Enterprise Manager on a remote computer
> (usually at another office), the MSSQL servers start sending packets to the
> EM regardless of whether we are maintaining an active connection to the
> server or not. What is happening is that these packets are being lost and
> reported in our firewall as 'host unreachable'. These packets are also
> firing every second for each EM open across our network, so this is becoming
> a bit of a pain for our poor network guys. The other odd thing is that the
> firewall is only reporting one-way traffic, from the server to the client,
> but the client is not sending any traffic back down unless it is actively
> connected to the remote server.
> Any thoughts as to why this might be happening, or better yet, a way to cull
> this traffic?
> We're running MSSQL 2000 SP3a on Windows 2003 servers.
> Thanks in advance!
> Mike,
>|||Define "entire SP3a hotfix". There is the service pack - SP3a - and then
there is the hotfix. Are you saying that you have applied SP3a but not the
hotfix? IOW, have you applied:
http://support.microsoft.com/kb/821277
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
news:5D90B16F-7EDB-401C-8022-106365D44347@.microsoft.com...
We have the entire SP3a hotfix installed, but I am unaware of a post SP3a
fix
- are you referring to SP4?
"Tom Moreau" wrote:
> Have you applied the post-SP3a hotfix?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> ..
> "Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
> news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
> We're having a bit of an issue with network traffic being generated from
> one
> of our MSSQL Servers.
> It seems that when we launch Enterprise Manager on a remote computer
> (usually at another office), the MSSQL servers start sending packets to
> the
> EM regardless of whether we are maintaining an active connection to the
> server or not. What is happening is that these packets are being lost and
> reported in our firewall as 'host unreachable'. These packets are also
> firing every second for each EM open across our network, so this is
> becoming
> a bit of a pain for our poor network guys. The other odd thing is that
> the
> firewall is only reporting one-way traffic, from the server to the client,
> but the client is not sending any traffic back down unless it is actively
> connected to the remote server.
> Any thoughts as to why this might be happening, or better yet, a way to
> cull
> this traffic?
> We're running MSSQL 2000 SP3a on Windows 2003 servers.
> Thanks in advance!
> Mike,
>

High Volume of Net Traffic coming from MSSQL

We're having a bit of an issue with network traffic being generated from one
of our MSSQL Servers.
It seems that when we launch Enterprise Manager on a remote computer
(usually at another office), the MSSQL servers start sending packets to the
EM regardless of whether we are maintaining an active connection to the
server or not. What is happening is that these packets are being lost and
reported in our firewall as 'host unreachable'. These packets are also
firing every second for each EM open across our network, so this is becoming
a bit of a pain for our poor network guys. The other odd thing is that the
firewall is only reporting one-way traffic, from the server to the client,
but the client is not sending any traffic back down unless it is actively
connected to the remote server.
Any thoughts as to why this might be happening, or better yet, a way to cull
this traffic?
We're running MSSQL 2000 SP3a on Windows 2003 servers.
Thanks in advance!
Mike,Have you applied the post-SP3a hotfix?
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
We're having a bit of an issue with network traffic being generated from one
of our MSSQL Servers.
It seems that when we launch Enterprise Manager on a remote computer
(usually at another office), the MSSQL servers start sending packets to the
EM regardless of whether we are maintaining an active connection to the
server or not. What is happening is that these packets are being lost and
reported in our firewall as 'host unreachable'. These packets are also
firing every second for each EM open across our network, so this is becoming
a bit of a pain for our poor network guys. The other odd thing is that the
firewall is only reporting one-way traffic, from the server to the client,
but the client is not sending any traffic back down unless it is actively
connected to the remote server.
Any thoughts as to why this might be happening, or better yet, a way to cull
this traffic?
We're running MSSQL 2000 SP3a on Windows 2003 servers.
Thanks in advance!
Mike,|||We have the entire SP3a hotfix installed, but I am unaware of a post SP3a fi
x
- are you referring to SP4?
"Tom Moreau" wrote:

> Have you applied the post-SP3a hotfix?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> ..
> "Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
> news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
> We're having a bit of an issue with network traffic being generated from o
ne
> of our MSSQL Servers.
> It seems that when we launch Enterprise Manager on a remote computer
> (usually at another office), the MSSQL servers start sending packets to th
e
> EM regardless of whether we are maintaining an active connection to the
> server or not. What is happening is that these packets are being lost and
> reported in our firewall as 'host unreachable'. These packets are also
> firing every second for each EM open across our network, so this is becomi
ng
> a bit of a pain for our poor network guys. The other odd thing is that th
e
> firewall is only reporting one-way traffic, from the server to the client,
> but the client is not sending any traffic back down unless it is actively
> connected to the remote server.
> Any thoughts as to why this might be happening, or better yet, a way to cu
ll
> this traffic?
> We're running MSSQL 2000 SP3a on Windows 2003 servers.
> Thanks in advance!
> Mike,
>|||Define "entire SP3a hotfix". There is the service pack - SP3a - and then
there is the hotfix. Are you saying that you have applied SP3a but not the
hotfix? IOW, have you applied:
http://support.microsoft.com/kb/821277
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
news:5D90B16F-7EDB-401C-8022-106365D44347@.microsoft.com...
We have the entire SP3a hotfix installed, but I am unaware of a post SP3a
fix
- are you referring to SP4?
"Tom Moreau" wrote:

> Have you applied the post-SP3a hotfix?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> ..
> "Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
> news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
> We're having a bit of an issue with network traffic being generated from
> one
> of our MSSQL Servers.
> It seems that when we launch Enterprise Manager on a remote computer
> (usually at another office), the MSSQL servers start sending packets to
> the
> EM regardless of whether we are maintaining an active connection to the
> server or not. What is happening is that these packets are being lost and
> reported in our firewall as 'host unreachable'. These packets are also
> firing every second for each EM open across our network, so this is
> becoming
> a bit of a pain for our poor network guys. The other odd thing is that
> the
> firewall is only reporting one-way traffic, from the server to the client,
> but the client is not sending any traffic back down unless it is actively
> connected to the remote server.
> Any thoughts as to why this might be happening, or better yet, a way to
> cull
> this traffic?
> We're running MSSQL 2000 SP3a on Windows 2003 servers.
> Thanks in advance!
> Mike,
>

High Volume of Net Traffic coming from MSSQL

We're having a bit of an issue with network traffic being generated from one
of our MSSQL Servers.
It seems that when we launch Enterprise Manager on a remote computer
(usually at another office), the MSSQL servers start sending packets to the
EM regardless of whether we are maintaining an active connection to the
server or not. What is happening is that these packets are being lost and
reported in our firewall as 'host unreachable'. These packets are also
firing every second for each EM open across our network, so this is becoming
a bit of a pain for our poor network guys. The other odd thing is that the
firewall is only reporting one-way traffic, from the server to the client,
but the client is not sending any traffic back down unless it is actively
connected to the remote server.
Any thoughts as to why this might be happening, or better yet, a way to cull
this traffic?
We're running MSSQL 2000 SP3a on Windows 2003 servers.
Thanks in advance!
Mike,
Have you applied the post-SP3a hotfix?
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
..
"Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
We're having a bit of an issue with network traffic being generated from one
of our MSSQL Servers.
It seems that when we launch Enterprise Manager on a remote computer
(usually at another office), the MSSQL servers start sending packets to the
EM regardless of whether we are maintaining an active connection to the
server or not. What is happening is that these packets are being lost and
reported in our firewall as 'host unreachable'. These packets are also
firing every second for each EM open across our network, so this is becoming
a bit of a pain for our poor network guys. The other odd thing is that the
firewall is only reporting one-way traffic, from the server to the client,
but the client is not sending any traffic back down unless it is actively
connected to the remote server.
Any thoughts as to why this might be happening, or better yet, a way to cull
this traffic?
We're running MSSQL 2000 SP3a on Windows 2003 servers.
Thanks in advance!
Mike,
|||We have the entire SP3a hotfix installed, but I am unaware of a post SP3a fix
- are you referring to SP4?
"Tom Moreau" wrote:

> Have you applied the post-SP3a hotfix?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> ..
> "Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
> news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
> We're having a bit of an issue with network traffic being generated from one
> of our MSSQL Servers.
> It seems that when we launch Enterprise Manager on a remote computer
> (usually at another office), the MSSQL servers start sending packets to the
> EM regardless of whether we are maintaining an active connection to the
> server or not. What is happening is that these packets are being lost and
> reported in our firewall as 'host unreachable'. These packets are also
> firing every second for each EM open across our network, so this is becoming
> a bit of a pain for our poor network guys. The other odd thing is that the
> firewall is only reporting one-way traffic, from the server to the client,
> but the client is not sending any traffic back down unless it is actively
> connected to the remote server.
> Any thoughts as to why this might be happening, or better yet, a way to cull
> this traffic?
> We're running MSSQL 2000 SP3a on Windows 2003 servers.
> Thanks in advance!
> Mike,
>
|||Define "entire SP3a hotfix". There is the service pack - SP3a - and then
there is the hotfix. Are you saying that you have applied SP3a but not the
hotfix? IOW, have you applied:
http://support.microsoft.com/kb/821277
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
..
"Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
news:5D90B16F-7EDB-401C-8022-106365D44347@.microsoft.com...
We have the entire SP3a hotfix installed, but I am unaware of a post SP3a
fix
- are you referring to SP4?
"Tom Moreau" wrote:

> Have you applied the post-SP3a hotfix?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> ..
> "Mike Schurkin" <MikeSchurkin@.discussions.microsoft.com> wrote in message
> news:C948BB2C-1A9D-4B73-9BDF-72B74A1FA9A2@.microsoft.com...
> We're having a bit of an issue with network traffic being generated from
> one
> of our MSSQL Servers.
> It seems that when we launch Enterprise Manager on a remote computer
> (usually at another office), the MSSQL servers start sending packets to
> the
> EM regardless of whether we are maintaining an active connection to the
> server or not. What is happening is that these packets are being lost and
> reported in our firewall as 'host unreachable'. These packets are also
> firing every second for each EM open across our network, so this is
> becoming
> a bit of a pain for our poor network guys. The other odd thing is that
> the
> firewall is only reporting one-way traffic, from the server to the client,
> but the client is not sending any traffic back down unless it is actively
> connected to the remote server.
> Any thoughts as to why this might be happening, or better yet, a way to
> cull
> this traffic?
> We're running MSSQL 2000 SP3a on Windows 2003 servers.
> Thanks in advance!
> Mike,
>

High reads

Some of my sps are showing high reads if executed from a >net application.
Like if sp is executed from .net app it shows some wayy around 5000000
reads and does not complete even in 10 min. Same sp , same time on th e same
server executes in 10 sec using sql query analyzer, and shows 30000 reads.
Can anyonme explains whats the problem?Bad query plans. Try adding the option WITH RECOMPILE to your stored
procedures.
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"VSS" <aa@.aa> wrote in message news:e04bYa6rGHA.2452@.TK2MSFTNGP03.phx.gbl...
> Some of my sps are showing high reads if executed from a >net application.
> Like if sp is executed from .net app it shows some wayy around 5000000
> reads and does not complete even in 10 min. Same sp , same time on th e
> same
> server executes in 10 sec using sql query analyzer, and shows 30000 reads.
> Can anyonme explains whats the problem?
>|||Check whether SET NCOUNT ON is set in SP .
M A Srinivas
VSS wrote:
> Some of my sps are showing high reads if executed from a >net application.
> Like if sp is executed from .net app it shows some wayy around 5000000
> reads and does not complete even in 10 min. Same sp , same time on th e sa
me
> server executes in 10 sec using sql query analyzer, and shows 30000 reads.
> Can anyonme explains whats the problem?

High reads

Some of my sps are showing high reads if executed from a >net application.
Like if sp is executed from .net app it shows some wayy around 5000000
reads and does not complete even in 10 min. Same sp , same time on th e same
server executes in 10 sec using sql query analyzer, and shows 30000 reads.
Can anyonme explains whats the problem?Bad query plans. Try adding the option WITH RECOMPILE to your stored
procedures.
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"VSS" <aa@.aa> wrote in message news:e04bYa6rGHA.2452@.TK2MSFTNGP03.phx.gbl...
> Some of my sps are showing high reads if executed from a >net application.
> Like if sp is executed from .net app it shows some wayy around 5000000
> reads and does not complete even in 10 min. Same sp , same time on th e
> same
> server executes in 10 sec using sql query analyzer, and shows 30000 reads.
> Can anyonme explains whats the problem?
>|||Check whether SET NCOUNT ON is set in SP .
M A Srinivas
VSS wrote:
> Some of my sps are showing high reads if executed from a >net application.
> Like if sp is executed from .net app it shows some wayy around 5000000
> reads and does not complete even in 10 min. Same sp , same time on th e same
> server executes in 10 sec using sql query analyzer, and shows 30000 reads.
> Can anyonme explains whats the problem?

Wednesday, March 21, 2012

High load SqlServer failes throwing error 3926 - what is that?

It manisfests itself in our SqlClient use (i.e. .NET 2.0) on one client side only...

with dozens of messages like:

ASP.global_asax - System.Data.SqlClient.SqlException : Server failed to resume the transaction, desc: 3500000c5b.

The transaction active in this session has been committed or aborted by another session.

That poins to SQL Server error 3926.

But I have NO clue how that comes. Anyone an idea? The code works flawless under dozens of other systems.

This looks like a exception throwed by SQL engine.

Guess what - it is SQL Error 3926 indicated by SQL Server. I already found that out and I already said so.

From "The transaction active in this session has been committed or aborted by another session.", I think more than one session in your application are accessing one transaction.

No chance. Here is the problem. I have, in the complete application, exactly 8 methods that do SQL processing. EVERY ONE of them:

* Gets a connection
* Establishes a transaction
* does it's job
* Closes the transaction
* Closes the connection

There is no open transaction ever left. All conenctions are properly disposed in a finally clause of a try/catch block in the method.

In fact, all my methods look like this:

Start:

IDbConnection connection = GetConnection ();
IDbTransaction txn = null;
if (System.Transactions.Transaction.Current == null) {
txn = connection.BeginTransaction ();
}
try {

processing

} finally {
if (txn == null) {
txn.Rollback ();
txn.Dispose ();
txn = null;
}
if (connection != null) {
connection.Close ();
connection.Dispose ();
connection = null;
}

If an error would happen in the finally block, I would see it. This is the pattern ALL my methods follow. This is the only location I actually open a connection. And I have a total of 8 methods that actually use the GetConnection method - and all run through the same pattern.

That is why I am ripping my hairs out. We DO close all transactions. I do NOT reuse transactions. This stuff is as simple as it gets. How the heck CAN anything go wrong here?

Normally, you can take a sql profiler trace to find out why.

Did you actually ever try that? I said "under high load". That server is basically like processing 2000 or so sql statements a SECOND for minutes before that thing slowly starts to materialize. The error does NOT appear under low or medium load. As a matter of fact, I have been unsuccessfull in replicating it in the lab. I get it on one customer's system, and I get it occasionally on one of our hosting systems for one customer (who uses a lot of ressources). It is critical for the one customer with his own system, because I sometimes get 10 or so of those a minute. In both scenarios where the error happens I can not turn on tracing for obvious reasons. And again, in the lab I was not successfull replicating it.

But I simply am totally our of ideas on what causes this. It should just not happen.

|||Did anybody solve this problem ?

High load SqlServer failes throwing error 3926 - what is that?

It manisfests itself in our SqlClient use (i.e. .NET 2.0) on one client side only...

with dozens of messages like:

ASP.global_asax - System.Data.SqlClient.SqlException : Server failed to resume the transaction, desc: 3500000c5b.

The transaction active in this session has been committed or aborted by another session.

That poins to SQL Server error 3926.

But I have NO clue how that comes. Anyone an idea? The code works flawless under dozens of other systems.

This looks like a exception throwed by SQL engine.

Guess what - it is SQL Error 3926 indicated by SQL Server. I already found that out and I already said so.

From "The transaction active in this session has been committed or aborted by another session.", I think more than one session in your application are accessing one transaction.

No chance. Here is the problem. I have, in the complete application, exactly 8 methods that do SQL processing. EVERY ONE of them:

* Gets a connection
* Establishes a transaction
* does it's job
* Closes the transaction
* Closes the connection

There is no open transaction ever left. All conenctions are properly disposed in a finally clause of a try/catch block in the method.

In fact, all my methods look like this:

Start:

IDbConnection connection = GetConnection ();
IDbTransaction txn = null;
if (System.Transactions.Transaction.Current == null) {
txn = connection.BeginTransaction ();
}
try {

processing

} finally {
if (txn == null) {
txn.Rollback ();
txn.Dispose ();
txn = null;
}
if (connection != null) {
connection.Close ();
connection.Dispose ();
connection = null;
}

If an error would happen in the finally block, I would see it. This is the pattern ALL my methods follow. This is the only location I actually open a connection. And I have a total of 8 methods that actually use the GetConnection method - and all run through the same pattern.

That is why I am ripping my hairs out. We DO close all transactions. I do NOT reuse transactions. This stuff is as simple as it gets. How the heck CAN anything go wrong here?

Normally, you can take a sql profiler trace to find out why.

Did you actually ever try that? I said "under high load". That server is basically like processing 2000 or so sql statements a SECOND for minutes before that thing slowly starts to materialize. The error does NOT appear under low or medium load. As a matter of fact, I have been unsuccessfull in replicating it in the lab. I get it on one customer's system, and I get it occasionally on one of our hosting systems for one customer (who uses a lot of ressources). It is critical for the one customer with his own system, because I sometimes get 10 or so of those a minute. In both scenarios where the error happens I can not turn on tracing for obvious reasons. And again, in the lab I was not successfull replicating it.

But I simply am totally our of ideas on what causes this. It should just not happen.

|||Did anybody solve this problem ?
sql

Monday, March 19, 2012

high cpu, low speed

i have high cpu problem. i don't know why many .net sqlclinet data
provider and IIS hold so much cpu resource. by the way, memery
condition is normal.

when i restart sqlserver, from windows task manager, i see the cpu time
of sqlserver.exe process is low, but it grows gradually, and in two
days, it can grow to as high as 2:xx:xx.

any one can tell me why .net sqlclinet data provider and IIS hold so
much cpu resource? and why cpu time of sqlserver.exe grows gradually?
thanks a lot.

below is the part of a trace report:

TextDataApplicationNameDurationStartTimeReadsWritesCPU
NULL.Net SqlClient Data Provider189123357:46.529168411040076
NULL.Net SqlClient Data Provider277798310:19.27923583730414
NULL.Net SqlClient Data Provider189504657:42.722503411526282
NULL.Net SqlClient Data Provider189957657:38.2161560740425570
NULLInternet Information Services43009602:52.77042962721518
NULL.Net SqlClient Data Provider277362310:19.16577581019828
NULL.Net SqlClient Data Provider68673308:21.03144731014904
NULLInternet Information Services33395630:11.666142618512188
NULLInternet Information Services60609310:07.49384117111124
NULL.Net SqlClient Data Provider37281323:04.9111621010686
NULL.Net SqlClient Data Provider170658028:33.72410832077626
NULLInternet Information Services64606024:35.3238936207390
NULL.Net SqlClient Data Provider109062338:32.911946207109
NULL.Net SqlClient Data Provider89465642:20.85394306778
NULL.Net SqlClient Data Provider78986006:40.766466706483
NULL.Net SqlClient Data Provider68856331:44.82884206420
NULL.Net SqlClient Data Provider79023344:29.73802006077
NULL.Net SqlClient Data Provider56975000:21.587254356049
NULL.Net SqlClient Data Provider110423338:12.911020565453
NULL.Net SqlClient Data Provider56978000:21.5111749415217
NULL.Net SqlClient Data Provider149207631:42.65649825122
NULL.Net SqlClient Data Provider142872027:40.27825734877
NULL.Net SqlClient Data Provider173951628:27.111265694653
NULL.Net SqlClient Data Provider169073328:26.59107804640
NULL.Net SqlClient Data Provider40656306:52.74912304391
NULL.Net SqlClient Data Provider56973601:17.73792804344
NULL.Net SqlClient Data Provider87886028:25.46157204280
NULL.Net SqlClient Data Provider78981306:40.7160337554279
NULL.Net SqlClient Data Provider28615610:42.01521704172
NULL.Net SqlClient Data Provider180126328:07.98573904138
NULL.Net SqlClient Data Provider26623352:11.54391104048
NULL.Net SqlClient Data Provider42412613:13.33311404046
NULL.Net SqlClient Data Provider45828349:48.71569404014
NULL.Net SqlClient Data Provider59893648:20.44212603983
NULLInternet Information Services38987657:32.910983643923
NULL.Net SqlClient Data Provider40825051:56.11565203922
NULL.Net SqlClient Data Provider44153050:05.41727103906
NULL.Net SqlClient Data Provider49392303:29.66312503890
NULL.Net SqlClient Data Provider35761025:20.51493003797
NULL.Net SqlClient Data Provider35456343:38.81570403782
NULL.Net SqlClient Data Provider37890649:44.61523103689
NULL.Net SqlClient Data Provider36323643:30.21596403673
NULL.Net SqlClient Data Provider43392348:08.21566003672
NULL.Net SqlClient Data Provider22059321:53.91434903645
NULL.Net SqlClient Data Provider184018628:04.68771003637
NULL.Net SqlClient Data Provider40776351:38.71646203595
NULL.Net SqlClient Data Provider40970350:47.01393003389
NULL.Net SqlClient Data Provider65773645:36.83863503376
NULL.Net SqlClient Data Provider44501348:17.71387003342
NULL.Net SqlClient Data Provider40331351:24.91290503266
NULLInternet Information Services60418628:05.5146475413035
NULLInternet Information Services60220337:13.79609252955
NULL.Net SqlClient Data Provider34518623:32.612010402955
NULL.Net SqlClient Data Provider30251314:52.01217902937
NULL.Net SqlClient Data Provider37945357:47.331948102891
NULL.Net SqlClient Data Provider35692347:15.61096402564
NULL.Net SqlClient Data Provider37964019:33.51062602453
NULL.Net SqlClient Data Provider161006329:47.711812422391
NULL.Net SqlClient Data Provider75999648:30.68796232376
NULL.Net SqlClient Data Provider76001348:30.65651302187
NULL.Net SqlClient Data Provider158300030:14.79316502157
NULLInternet Information Services55791032:46.851272111967
NULLInternet Information Services25312653:29.67935541893
NULL.Net SqlClient Data Provider95000027:14.33036801875
NULL.Net SqlClient Data Provider56968607:22.5112528421842
NULLInternet Information Services21875054:04.03855301811
NULL.Net SqlClient Data Provider126831335:28.4162994581782
NULL.Net SqlClient Data Provider141667332:47.97308401674
NULLInternet Information Services55525047:41.07781181639
NULL.Net SqlClient Data Provider88247028:21.84272901638
NULLInternet Information Services25129653:31.553638181626
NULL.Net SqlClient Data Provider88981328:14.44857501625
NULLInternet Information Services19851600:16.159345501580
NULL.Net SqlClient Data Provider56970601:17.77347301576
NULLInternet Information Services52651647:51.24524581565
NULL.Net SqlClient Data Provider37881326:26.96875301467
NULL.Net SqlClient Data Provider81989043:15.75487301312
NULLInternet Information Services37651632:48.275602141297
NULL.Net SqlClient Data Provider30257614:51.91455351801266
NULL.Net SqlClient Data Provider94970357:49.66191501238
NULL.Net SqlClient Data Provider34781323:29.93622901203
NULL.Net SqlClient Data Provider76679630:17.53368101170
NULL.Net SqlClient Data Provider107081039:00.44675901109
NULL.Net SqlClient Data Provider49532648:22.548276101095
NULL.Net SqlClient Data Provider50011048:49.252299511078
NULL.Net SqlClient Data Provider37954657:49.7448401062
NULL.Net SqlClient Data Provider88336028:20.94006501049
NULL.Net SqlClient Data Provider24511033:33.0489701032
NULL.Net SqlClient Data Provider88495328:19.33754801031
NULL.Net SqlClient Data Provider60478303:26.6451490968
NULL.Net SqlClient Data Provider49395303:29.5640980955
NULL.Net SqlClient Data Provider54786019:17.0377930938
NULLInternet Information Services29589006:38.7446491907
NULL.Net SqlClient Data Provider33442300:18.767960891
NULL.Net SqlClient Data Provider86037628:43.9126870858
NULLInternet Information Services40493639:47.8471172843
NULL.Net SqlClient Data Provider68973331:53.8315881796
NULL.Net SqlClient Data Provider50568649:43.33473121796
NULL.Net SqlClient Data Provider50345348:13.1276641764
NULL.Net SqlClient Data Provider72609348:20.5210820702
NULL.Net SqlClient Data Provider24520333:32.9381320688
NULL.Net SqlClient Data Provider28625010:41.9285548686
NULL.Net SqlClient Data Provider173781330:13.5169100659
NULL.Net SqlClient Data Provider34089023:36.953030625
NULL.Net SqlClient Data Provider34144023:36.327820625
NULL.Net SqlClient Data Provider41397050:40.9287224610
NULL.Net SqlClient Data Provider34073323:37.0213300608
NULL.Net SqlClient Data Provider53148348:02.7270060595
NULL.Net SqlClient Data Provider35764025:20.5402862594
NULL.Net SqlClient Data Provider56892033:54.6284070593
declare @.P1 int set @.P1=1033 declare @.P2 int set @.P2=20644 exec
p_splitpage @.sql = 'Select
UserName,Status,Qymc,Qylb,areaCode1,SiteHits,Zycp, CONVERT
(varchar(300), Qyjj) AS Qyjj,QyjjStatus,compPhone,compFax From UserInfo
Where isValid=1 and Right(Status,1).Net SqlClient Data
Provider481308:18.211296955578
NULL.Net SqlClient Data Provider49670348:13.6268720563
NULL.Net SqlClient Data Provider49137349:58.5275230562
NULL.Net SqlClient Data Provider37967019:33.5404290562
NULLInternet Information Services39212632:22.61511612543
NULL.Net SqlClient Data Provider51453048:13.0228450532
NULL.Net SqlClient Data Provider65514048:42.740750531
declare @.P1 int set @.P1=5587 declare @.P2 int set @.P2=55867 exec
p_splitpage @.sql = 'Select
Info.picPath,Info.Info_ID,Info.postUser,Info.infoT ype,Info.infoLevel,Info.infoDirect,Info.showname,I nfo.postDateTime,Info.areaCode,CONVERT
(varchar(300), Info.conten.Net SqlClient Data
Provider94014:55.0139021180516
exec p_splitpage 'Select
ID,UserName,PassWord,Qymc,RegisterTime,name,Phone From UserInfo Where
isValid = 1 and UserName like ''%nick%'' and
SUBSTRING(Status,2,3)=''019'' Order By ID DESC',0,30Internet
Information Services131335:39.814030516
NULL.Net SqlClient Data Provider24104607:30.7216430514
NULL.Net SqlClient Data Provider56918635:46.737300499
NULL.Net SqlClient Data Provider36893650:51.7199720486
NULL.Net SqlClient Data Provider102501628:10.9231642485
NULL.Net SqlClient Data Provider54798619:16.9340860485
NULL.Net SqlClient Data Provider42397013:13.4397300483
NULL.Net SqlClient Data Provider37964012:11.1330690470
NULLInternet Information Services18441037:30.3261545468
NULL.Net SqlClient Data Provider43448606:16.9191610468
NULL.Net SqlClient Data Provider36296652:15.4190060436
NULLInternet Information Services11064001:43.984251422
NULL.Net SqlClient Data Provider37975057:40.8210330419
NULL.Net SqlClient Data Provider5279655:44.9159260406
NULL.Net SqlClient Data Provider33442300:18.7325502392
NULLInternet Information Services11436047:40.4148070390
NULL.Net SqlClient Data Provider39812636:26.138510343
NULL.Net SqlClient Data Provider155228331:21.2164340329
NULL.Net SqlClient Data Provider4187655:55.8164293328
NULL.Net SqlClient Data Provider36928023:08.5144192328
Select Count(ID) From UserInfo Where isValid=1 and Right(Status,1)<>'0'
and hy = '0019'.Net SqlClient Data Provider98308:31.9232480298
SELECT TOP 5 L.title, L.siteUrl FROM Links L INNER JOIN LinksCategory C
ON C.PKID = L.CategoryID INNER JOIN LinksType T ON T.typeID = C.typeID
WHERE (T.typeID = 7).Net SqlClient Data
Provider3057654:41.622720282If i recall correctly, CPUTime is the cumulative time spent. It is NOT
the amount of the CPU that is currently being used, but rather the
amount of cpu time that has been used since the process started.

Wednesday, March 7, 2012

Hierarchical data with any DataReader

Hello,
I have two problems to resolve with .NET 1.1:
1. I search the good way to read hierarchical data with a SqlDataReader.
I don't know if it's possible. Must I use inevitably an
OleDbDataReader with SHAPE ... APPEND ...
2. How read hierarchical data on the same table with SQL server 2000 and
a SqlDataReader ?
Thanks for your help,
Christopher.Hi
You take a look at very good examples about the issue written by Itzik Ben-
Gan. However it does not cover .NET SqlDataReader object to read the data
but I'm sure you will get an idea
IF object_id('dbo.Employees') IS NOT NULL
DROP TABLE Employees
GO
IF object_id('dbo.ufn_GetSubtree') IS NOT NULL
DROP FUNCTION dbo.ufn_GetSubtree
GO
CREATE TABLE Employees
(
empid int NOT NULL,
mgrid int NULL,
empname varchar(25) NOT NULL,
salary money NOT NULL,
CONSTRAINT PK_Employees_empid PRIMARY KEY(empid),
CONSTRAINT FK_Employees_mgrid_empid
FOREIGN KEY(mgrid)
REFERENCES Employees(empid)
)
CREATE INDEX idx_nci_mgrid ON Employees(mgrid)
INSERT INTO Employees VALUES(1 , NULL, 'Nancy' , $10000.00)
INSERT INTO Employees VALUES(2 , 1 , 'Andrew' , $5000.00)
INSERT INTO Employees VALUES(3 , 1 , 'Janet' , $5000.00)
INSERT INTO Employees VALUES(4 , 1 , 'Margaret', $5000.00)
INSERT INTO Employees VALUES(5 , 2 , 'Steven' , $2500.00)
INSERT INTO Employees VALUES(6 , 2 , 'Michael' , $2500.00)
INSERT INTO Employees VALUES(7 , 3 , 'Robert' , $2500.00)
INSERT INTO Employees VALUES(8 , 3 , 'Laura' , $2500.00)
INSERT INTO Employees VALUES(9 , 3 , 'Ann' , $2500.00)
INSERT INTO Employees VALUES(10, 4 , 'Ina' , $2500.00)
INSERT INTO Employees VALUES(11, 7 , 'David' , $2000.00)
INSERT INTO Employees VALUES(12, 7 , 'Ron' , $2000.00)
INSERT INTO Employees VALUES(13, 7 , 'Dan' , $2000.00)
INSERT INTO Employees VALUES(14, 11 , 'James' , $1500.00)
GO
CREATE FUNCTION dbo.ufn_GetSubtree
(
@.mgrid AS int
)
RETURNS @.tree table
(
empid int NOT NULL,
mgrid int NULL,
empname varchar(25) NOT NULL,
salary money NOT NULL,
lvl int NOT NULL,
path varchar(900) NOT NULL
)
AS
BEGIN
DECLARE @.lvl AS int, @.path AS varchar(900)
SELECT @.lvl = 0, @.path = '.'
INSERT INTO @.tree
SELECT empid, mgrid, empname, salary,
@.lvl, '.' + CAST(empid AS varchar(10)) + '.'
FROM Employees
WHERE empid = @.mgrid
WHILE @.@.ROWCOUNT > 0
BEGIN
SET @.lvl = @.lvl + 1
INSERT INTO @.tree
SELECT E.empid, E.mgrid, E.empname, E.salary,
@.lvl, T.path + CAST(E.empid AS varchar(10)) + '.'
FROM Employees AS E JOIN @.tree AS T
ON E.mgrid = T.empid AND T.lvl = @.lvl - 1
END
RETURN
END
GO
SELECT empid, mgrid, empname, salary
FROM ufn_GetSubtree(3)
GO
/*
empid mgrid empname salary
2 1 Andrew 5000.0000
5 2 Steven 2500.0000
6 2 Michael 2500.0000
*/
-- Scalar functions --
--
-- Getting Ancestor using Recursion
CREATE FUNCTION dbo.ufn_GetAncestor
(
@.empid AS int,
@.lvl AS int = 1 -- levels above employee
)
RETURNS int
AS
BEGIN
IF @.lvl IS NULL or @.empid IS NULL or @.lvl < 0
RETURN NULL
IF @.lvl = 0
RETURN @.empid
RETURN dbo.ufn_GetAncestor(
(SELECT mgrid FROM Employees WHERE empid = @.empid),
@.lvl -1)
END
GO
-- Getting Ancestor using a Loop
CREATE FUNCTION dbo.ufn_GetAncestor2
(
@.empid AS int,
@.lvl AS int = 1 -- levels above employee
)
RETURNS int
AS
BEGIN
IF @.lvl IS NULL or @.empid IS NULL or @.lvl < 0
RETURN NULL
DECLARE @.mgrid AS int
SET @.mgrid = @.empid
WHILE @.lvl > 0 AND @.mgrid IS NOT NULL
SELECT @.mgrid = mgrid, @.lvl = @.lvl - 1
FROM Employees WHERE empid = @.mgrid
RETURN @.mgrid
END
GO
-- test the dbo.ufn_GetAncestor function
SELECT dbo.ufn_GetAncestor(11, 2)
SELECT * FROM Employees WHERE empid = dbo.ufn_GetAncestor(11, 2)
SELECT E.empname AS employee, A.empname AS ancestor
FROM Employees AS E LEFT OUTER JOIN Employees AS A
ON A.empid = dbo.ufn_GetAncestor(E.empid, 2)
GO
-- Calculating an Aggregate of a Subtree
CREATE FUNCTION dbo.ufn_GetSubtreeSalary
(
@.mgrid AS int
)
RETURNS int
AS
BEGIN
RETURN (SELECT Salary
FROM Employees WHERE empid = @.mgrid) +
CASE
WHEN EXISTS(SELECT * FROM Employees WHERE mgrid = @.mgrid) THEN
(SELECT SUM(dbo.ufn_GetSubtreeSalary(empid))
FROM Employees
WHERE mgrid = @.mgrid)
ELSE 0
END
END
GO
SELECT dbo.ufn_GetSubtreeSalary(3)
GO
-- Calculating the Depth of a Subtree
CREATE FUNCTION dbo.ufn_GetSubtreeDepth
(
@.mgrid AS int
)
RETURNS int
AS
BEGIN
RETURN CASE
WHEN EXISTS(SELECT * FROM Employees WHERE mgrid = @.mgrid) THEN
1 + (SELECT MAX(dbo.ufn_GetSubtreeDepth(empid))
FROM Employees
WHERE mgrid = @.mgrid)
WHEN EXISTS(SELECT * FROM Employees WHERE empid = @.mgrid) THEN 1
ELSE NULL
END
END
GO
SELECT dbo.ufn_GetSubtreeDepth(1)
GO

"Christopher" <Dev@.effect.fr> wrote in message
news:eAngpiOIGHA.2680@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have two problems to resolve with .NET 1.1:
> 1. I search the good way to read hierarchical data with a
> SqlDataReader.
> I don't know if it's possible. Must I use inevitably an
> OleDbDataReader with SHAPE ... APPEND ...
> 2. How read hierarchical data on the same table with SQL server 2000
> and
> a SqlDataReader ?
> Thanks for your help,
> Christopher.
>
>|||Thanks for these informations.
"Uri Dimant" <urid@.iscar.co.il> a crit dans le message de news:
%23ppmLpOIGHA.2064@.TK2MSFTNGP09.phx.gbl...
> Hi
> You take a look at very good examples about the issue written by Itzik
> Ben- Gan. However it does not cover .NET SqlDataReader object to read
> the data but I'm sure you will get an idea
> IF object_id('dbo.Employees') IS NOT NULL
> DROP TABLE Employees
> GO
> IF object_id('dbo.ufn_GetSubtree') IS NOT NULL
> DROP FUNCTION dbo.ufn_GetSubtree
> GO
> CREATE TABLE Employees
> (
> empid int NOT NULL,
> mgrid int NULL,
> empname varchar(25) NOT NULL,
> salary money NOT NULL,
> CONSTRAINT PK_Employees_empid PRIMARY KEY(empid),
> CONSTRAINT FK_Employees_mgrid_empid
> FOREIGN KEY(mgrid)
> REFERENCES Employees(empid)
> )
> CREATE INDEX idx_nci_mgrid ON Employees(mgrid)
> INSERT INTO Employees VALUES(1 , NULL, 'Nancy' , $10000.00)
> INSERT INTO Employees VALUES(2 , 1 , 'Andrew' , $5000.00)
> INSERT INTO Employees VALUES(3 , 1 , 'Janet' , $5000.00)
> INSERT INTO Employees VALUES(4 , 1 , 'Margaret', $5000.00)
> INSERT INTO Employees VALUES(5 , 2 , 'Steven' , $2500.00)
> INSERT INTO Employees VALUES(6 , 2 , 'Michael' , $2500.00)
> INSERT INTO Employees VALUES(7 , 3 , 'Robert' , $2500.00)
> INSERT INTO Employees VALUES(8 , 3 , 'Laura' , $2500.00)
> INSERT INTO Employees VALUES(9 , 3 , 'Ann' , $2500.00)
> INSERT INTO Employees VALUES(10, 4 , 'Ina' , $2500.00)
> INSERT INTO Employees VALUES(11, 7 , 'David' , $2000.00)
> INSERT INTO Employees VALUES(12, 7 , 'Ron' , $2000.00)
> INSERT INTO Employees VALUES(13, 7 , 'Dan' , $2000.00)
> INSERT INTO Employees VALUES(14, 11 , 'James' , $1500.00)
> GO
> CREATE FUNCTION dbo.ufn_GetSubtree
> (
> @.mgrid AS int
> )
> RETURNS @.tree table
> (
> empid int NOT NULL,
> mgrid int NULL,
> empname varchar(25) NOT NULL,
> salary money NOT NULL,
> lvl int NOT NULL,
> path varchar(900) NOT NULL
> )
> AS
> BEGIN
> DECLARE @.lvl AS int, @.path AS varchar(900)
> SELECT @.lvl = 0, @.path = '.'
> INSERT INTO @.tree
> SELECT empid, mgrid, empname, salary,
> @.lvl, '.' + CAST(empid AS varchar(10)) + '.'
> FROM Employees
> WHERE empid = @.mgrid
> WHILE @.@.ROWCOUNT > 0
> BEGIN
> SET @.lvl = @.lvl + 1
> INSERT INTO @.tree
> SELECT E.empid, E.mgrid, E.empname, E.salary,
> @.lvl, T.path + CAST(E.empid AS varchar(10)) + '.'
> FROM Employees AS E JOIN @.tree AS T
> ON E.mgrid = T.empid AND T.lvl = @.lvl - 1
> END
> RETURN
> END
> GO
> SELECT empid, mgrid, empname, salary
> FROM ufn_GetSubtree(3)
> GO
> /*
> empid mgrid empname salary
> 2 1 Andrew 5000.0000
> 5 2 Steven 2500.0000
> 6 2 Michael 2500.0000
> */
>
> -- Scalar functions --
> --
> -- Getting Ancestor using Recursion
> CREATE FUNCTION dbo.ufn_GetAncestor
> (
> @.empid AS int,
> @.lvl AS int = 1 -- levels above employee
> )
> RETURNS int
> AS
> BEGIN
> IF @.lvl IS NULL or @.empid IS NULL or @.lvl < 0
> RETURN NULL
> IF @.lvl = 0
> RETURN @.empid
> RETURN dbo.ufn_GetAncestor(
> (SELECT mgrid FROM Employees WHERE empid = @.empid),
> @.lvl -1)
> END
> GO
> -- Getting Ancestor using a Loop
> CREATE FUNCTION dbo.ufn_GetAncestor2
> (
> @.empid AS int,
> @.lvl AS int = 1 -- levels above employee
> )
> RETURNS int
> AS
> BEGIN
> IF @.lvl IS NULL or @.empid IS NULL or @.lvl < 0
> RETURN NULL
> DECLARE @.mgrid AS int
> SET @.mgrid = @.empid
> WHILE @.lvl > 0 AND @.mgrid IS NOT NULL
> SELECT @.mgrid = mgrid, @.lvl = @.lvl - 1
> FROM Employees WHERE empid = @.mgrid
> RETURN @.mgrid
> END
> GO
> -- test the dbo.ufn_GetAncestor function
> SELECT dbo.ufn_GetAncestor(11, 2)
> SELECT * FROM Employees WHERE empid = dbo.ufn_GetAncestor(11, 2)
> SELECT E.empname AS employee, A.empname AS ancestor
> FROM Employees AS E LEFT OUTER JOIN Employees AS A
> ON A.empid = dbo.ufn_GetAncestor(E.empid, 2)
> GO
> -- Calculating an Aggregate of a Subtree
> CREATE FUNCTION dbo.ufn_GetSubtreeSalary
> (
> @.mgrid AS int
> )
> RETURNS int
> AS
> BEGIN
> RETURN (SELECT Salary
> FROM Employees WHERE empid = @.mgrid) +
> CASE
> WHEN EXISTS(SELECT * FROM Employees WHERE mgrid = @.mgrid) THEN
> (SELECT SUM(dbo.ufn_GetSubtreeSalary(empid))
> FROM Employees
> WHERE mgrid = @.mgrid)
> ELSE 0
> END
> END
> GO
> SELECT dbo.ufn_GetSubtreeSalary(3)
> GO
> -- Calculating the Depth of a Subtree
> CREATE FUNCTION dbo.ufn_GetSubtreeDepth
> (
> @.mgrid AS int
> )
> RETURNS int
> AS
> BEGIN
> RETURN CASE
> WHEN EXISTS(SELECT * FROM Employees WHERE mgrid = @.mgrid) THEN
> 1 + (SELECT MAX(dbo.ufn_GetSubtreeDepth(empid))
> FROM Employees
> WHERE mgrid = @.mgrid)
> WHEN EXISTS(SELECT * FROM Employees WHERE empid = @.mgrid) THEN 1
> ELSE NULL
> END
> END
> GO
> SELECT dbo.ufn_GetSubtreeDepth(1)
> GO
>
>
>
>
>
>
> "Christopher" <Dev@.effect.fr> wrote in message
> news:eAngpiOIGHA.2680@.TK2MSFTNGP09.phx.gbl...
>

Sunday, February 26, 2012

hiding/password Protecting Enterprise Manager

I have installed SQL 2000 and Enterprise Manager. I have a .Net application
I am developing. I need Enterprise Manager to make data table changes as I
finish my application, but I am afraid my test and final users will use the
Enterprise Manager to change data. I do not want users to change data
without using my application. Can I limit Enterprise Manager or password
protect or block access to other users?
Thanks
Paul DeWitt
Paul DeWitt wrote:
> I have installed SQL 2000 and Enterprise Manager. I have a .Net
> application I am developing. I need Enterprise Manager to make data
> table changes as I finish my application, but I am afraid my test and
> final users will use the Enterprise Manager to change data. I do not
> want users to change data without using my application. Can I limit
> Enterprise Manager or password protect or block access to other users?
> Thanks
> Paul DeWitt
Users can only perform operations that they have security to perform. If
you don't grant access to the tables and use stored procedures to change
and select data, then users logging into the database using any tool
(SQL Enterprise Manager, Query Analyzer, ISQL, OSQL, etc.) will not be
able to change any data unless they call the stored procedures from
those apps. If you do not provide some underlying security in the
database or your users have dbo or admin rights in the database, there
is nothing to prevent them from changing data and nothing you can really
do to stop it, short of encrypting yourself in the application.
David Gugick
Quest Software
www.imceda.com
www.quest.com
|||Check out application roles (sp_setapprole).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Paul DeWitt" <PaulDeWitt@.discussions.microsoft.com> wrote in message
news:E0B9510C-7A3A-4EBB-8EA7-A202FC715D1E@.microsoft.com...
>I have installed SQL 2000 and Enterprise Manager. I have a .Net application
> I am developing. I need Enterprise Manager to make data table changes as I
> finish my application, but I am afraid my test and final users will use the
> Enterprise Manager to change data. I do not want users to change data
> without using my application. Can I limit Enterprise Manager or password
> protect or block access to other users?
> Thanks
> Paul DeWitt

Hiding URL from User

I have a web application written in ASP, not ASP.Net. We set up a page with an iframe that we populate the SSRS reports into. The url of the report is visible through a right click/properties. Is there a way to either disable the right click or hide the url?

you can disable the right click by adding oncontextmenu="return false" in the body tag:

<body oncontextmenu="return false">

Hiding SOME parameters in the parameter toolbar

I am using the ReportViewer.dll in a ASP.NET web application. The report
being displayed takes 2 parameters. One of these is programmatically set. I
would like the user to select values only for the other parameter. So when
displaying the report within the control, can I just show the second
parameter on the toolbar and hide the first one?
The Parameters toolbar property in the ReportViewer control corresponds to
the 'Parameters' URL access parameter, which hides/displays the entire
parameter toolbar
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_prog_urlaccess_959e.asp). Umm, is that bad news?OK I solved the problem...You just type in a blank string for the Prompt
value...
"Aparna" wrote:
> I am using the ReportViewer.dll in a ASP.NET web application. The report
> being displayed takes 2 parameters. One of these is programmatically set. I
> would like the user to select values only for the other parameter. So when
> displaying the report within the control, can I just show the second
> parameter on the toolbar and hide the first one?
> The Parameters toolbar property in the ReportViewer control corresponds to
> the 'Parameters' URL access parameter, which hides/displays the entire
> parameter toolbar
> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_prog_urlaccess_959e.asp). Umm, is that bad news?|||On Wed, 26 Jan 2005 12:21:03 -0800, Aparna
<Aparna@.discussions.microsoft.com> wrote:
>OK I solved the problem...You just type in a blank string for the Prompt
>value...
>
How exactly does one "type in" a blank string? :)))
>"Aparna" wrote:
>> I am using the ReportViewer.dll in a ASP.NET web application. The report
>> being displayed takes 2 parameters. One of these is programmatically set. I
>> would like the user to select values only for the other parameter. So when
>> displaying the report within the control, can I just show the second
>> parameter on the toolbar and hide the first one?
>> The Parameters toolbar property in the ReportViewer control corresponds to
>> the 'Parameters' URL access parameter, which hides/displays the entire
>> parameter toolbar
>> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_prog_urlaccess_959e.asp). Umm, is that bad news?|||haha...Not quite sure...However, it turns out my excitement was in vain...If
the prompt value is not specified, then the paratmeter becomes Read-only..So,
if you programatically want to assign values to it, you are out of luck! The
only way to set the value of that parameter is via the parameter property
page. So my orginal problem still stands...SOMEBODY HELLLP...
"Usenet User" wrote:
> On Wed, 26 Jan 2005 12:21:03 -0800, Aparna
> <Aparna@.discussions.microsoft.com> wrote:
> >OK I solved the problem...You just type in a blank string for the Prompt
> >value...
> >
> How exactly does one "type in" a blank string? :)))
>
> >"Aparna" wrote:
> >
> >> I am using the ReportViewer.dll in a ASP.NET web application. The report
> >> being displayed takes 2 parameters. One of these is programmatically set. I
> >> would like the user to select values only for the other parameter. So when
> >> displaying the report within the control, can I just show the second
> >> parameter on the toolbar and hide the first one?
> >>
> >> The Parameters toolbar property in the ReportViewer control corresponds to
> >> the 'Parameters' URL access parameter, which hides/displays the entire
> >> parameter toolbar
> >> (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_prog_urlaccess_959e.asp). Umm, is that bad news?
>

Friday, February 24, 2012

Hiding Parameters

Is it easy to hide the parameters of a report? Im using the ReportViewer tag in asp.net and I have my own parameters that I am passing into my report. But when the report renders, it shows the default parameters that look terrible in my application.

I was wondering if there was a way to only have my own parameters showing?

Thanks in advance everyone
man, just after I posted this I found the exact thing I wanted, the code is as follows:

reportViewer.Parameters = Microsoft.Samples.ReportingServices.ReportViewer.multiState.False;

Hiding parameter passed through query string

I'm using Reporting Servicves for SQL Server 2000 and I've embedded a
ReportViewer control in an ASP.NET page. The reports I link to all require a
sensitive parameter value and I have been passing that through using the
query string. Unfortunately, the entire URL of the report--including the
parameter in the query string--is visible in the source for the page, and I
don't want the user to see this for security purposes.
Is there a way to hide this? I'm open to any and all suggestions.
Thanks,
MarkSearch the group on encryption - use System.Security.Cryptography package
I just repeat myself from a previous posting:
"Parameter's encryption is a key to solve your problem.
The simplest ( but not the only) way is:
1.create your own parameters collection pages (forms).
2. encrypt user input using a permanent or temporary encryption key.
3. Reference encryption assembly in your report designer.
4. use a decryption routine in your custom code akin
"=Code.Library.Decrypt(Parameters!account_id);" by retrieving an encryption
key used in step 2.
By using this approach even a simplest parameter will be totally un
guessable, because even a single digit will be encrypted to something like
"bHZiajB4TGpBdU1"
"
"Mark" <Mark@.discussions.microsoft.com> wrote in message
news:98599DF6-C0E8-418A-A573-8293EEE98E13@.microsoft.com...
> I'm using Reporting Servicves for SQL Server 2000 and I've embedded a
> ReportViewer control in an ASP.NET page. The reports I link to all require
> a
> sensitive parameter value and I have been passing that through using the
> query string. Unfortunately, the entire URL of the report--including the
> parameter in the query string--is visible in the source for the page, and
> I
> don't want the user to see this for security purposes.
> Is there a way to hide this? I'm open to any and all suggestions.
> Thanks,
> Mark|||For RS 2000 you can use web services. There is really no way using URL
integration to hide it from the source. You can hide it from the page being
displayed but if they go View, Source they will see it.
In VS 2005 there are two new controls that work with RS 2005. They use web
services under the covers, not URL integration. You do have to have RS 2005.
Note that you can upgrade to RS 2005 while leaving the database at 2000
(that is what I have done). You do need a SQL Server 2005 license for this
however.
My suggestion is if security is important then you use the new controls.
One other option, put the parameters in a database table and then pass the
primary key to the table and have a dataset extracting the parameters.
This does make things more complicated but it is a version independent
solution (if you can convince management to upgrade to RS 2005). Note what I
said about upgrading. Sometimes it is easier to get permission to upgrade
reporting services than it is to upgrade a SQL Server database.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Mark" <Mark@.discussions.microsoft.com> wrote in message
news:98599DF6-C0E8-418A-A573-8293EEE98E13@.microsoft.com...
> I'm using Reporting Servicves for SQL Server 2000 and I've embedded a
> ReportViewer control in an ASP.NET page. The reports I link to all require
> a
> sensitive parameter value and I have been passing that through using the
> query string. Unfortunately, the entire URL of the report--including the
> parameter in the query string--is visible in the source for the page, and
> I
> don't want the user to see this for security purposes.
> Is there a way to hide this? I'm open to any and all suggestions.
> Thanks,
> Mark|||Good point. I forgot about doing that.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Oleg Yevteyev" <myfirstname001atgmaildotcom> wrote in message
news:OdtQOZxCGHA.1816@.TK2MSFTNGP11.phx.gbl...
> Search the group on encryption - use System.Security.Cryptography package
> I just repeat myself from a previous posting:
> "Parameter's encryption is a key to solve your problem.
> The simplest ( but not the only) way is:
> 1.create your own parameters collection pages (forms).
> 2. encrypt user input using a permanent or temporary encryption key.
> 3. Reference encryption assembly in your report designer.
> 4. use a decryption routine in your custom code akin
> "=Code.Library.Decrypt(Parameters!account_id);" by retrieving an
> encryption
> key used in step 2.
> By using this approach even a simplest parameter will be totally un
> guessable, because even a single digit will be encrypted to something like
> "bHZiajB4TGpBdU1"
> "
>
> "Mark" <Mark@.discussions.microsoft.com> wrote in message
> news:98599DF6-C0E8-418A-A573-8293EEE98E13@.microsoft.com...
>> I'm using Reporting Servicves for SQL Server 2000 and I've embedded a
>> ReportViewer control in an ASP.NET page. The reports I link to all
>> require a
>> sensitive parameter value and I have been passing that through using the
>> query string. Unfortunately, the entire URL of the report--including the
>> parameter in the query string--is visible in the source for the page, and
>> I
>> don't want the user to see this for security purposes.
>> Is there a way to hide this? I'm open to any and all suggestions.
>> Thanks,
>> Mark
>