Showing posts with label service. Show all posts
Showing posts with label service. Show all posts

Thursday, March 8, 2012

dead lock problem

Version: SQL Server 2000 8.00.818
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
I have been asked to look into a problem in one of the database
at our client site. I have very little idea of the application.
It seems they are facing intermittent deadlock problem. This is the
query of the session which is *always* rolled back.
SELECT air_itin_fare_calc.air_itin_price_id, air_itin_price.air_itin_id,
...
FROM air_itin_price, air_itin_fare_calc
WHERE air_itin_price.air_itin_id = ?
AND air_itin_price.air_itin_price_id = air_itin_fare_calc.air_itin_price_id
order by air_itin_fare_calc.air_itin_price_id
The index on the two tables
ALTER TABLE [dbo].[air_itin_price] WITH NOCHECK ADD
CONSTRAINT [PK_air_itin_price] PRIMARY KEY CLUSTERED
(
[air_itin_id],
[psgr_type]
) WITH FILLFACTOR = 50 ON [PRIMARY]
CREATE CLUSTERED INDEX [PK_air_itin_price_id] ON
[dbo].[air_itin_fare_calc]([air_itin_price_id]) ON [PRIMARY]
CREATE INDEX [air_itin_price_airitinpriceid] ON
[dbo].[air_itin_price]([air_itin_price_id]) ON [PRIMARY]
This is a read only query only, even though the isolation level is same for
all sessions (SERIALIZABLE).
Since the columns in the WHERE CLAUSE is indexed, I assume that SQLServer wi
ll
use key locks only. I am bit concerned about CLUSTERED INDEX. Is the behavio
r
same with CLUSTERED INDEX also. I also notice that the primary key on the ta
ble
air_itin_price is a composite index on air_itin_id + psgr_type. But the quer
y
is only for air_itin_id. Does that make a difference?
Any pointers will be appreciated."rkusenet" <rkusenet@.sympatico.ca> wrote in message
news:c3fkhh$28a94j$1@.ID-75254.news.uni-berlin.de...
> Version: SQL Server 2000 8.00.818
> Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
> I have been asked to look into a problem in one of the database
> at our client site. I have very little idea of the application.
> It seems they are facing intermittent deadlock problem. This is the
> query of the session which is *always* rolled back.
>
> SELECT air_itin_fare_calc.air_itin_price_id, air_itin_price.air_itin_id,
> ...
> FROM air_itin_price, air_itin_fare_calc
> WHERE air_itin_price.air_itin_id = ?
> AND air_itin_price.air_itin_price_id = air_itin_fare_calc.air_itin_price_i
d
> order by air_itin_fare_calc.air_itin_price_id
> The index on the two tables
> ALTER TABLE [dbo].[air_itin_price] WITH NOCHECK ADD
> CONSTRAINT [PK_air_itin_price] PRIMARY KEY CLUSTERED
> (
> [air_itin_id],
> [psgr_type]
> ) WITH FILLFACTOR = 50 ON [PRIMARY]
> CREATE CLUSTERED INDEX [PK_air_itin_price_id] ON
> [dbo].[air_itin_fare_calc]([air_itin_price_id]) ON [PRIMAR
Y]
> CREATE INDEX [air_itin_price_airitinpriceid] ON
> [dbo].[air_itin_price]([air_itin_price_id]) ON [PRIMARY]
> This is a read only query only, even though the isolation level is same fo
r
> all sessions (SERIALIZABLE).
> Since the columns in the WHERE CLAUSE is indexed, I assume that SQLServer
will
> use key locks only. I am bit concerned about CLUSTERED INDEX. Is the behav
ior
> same with CLUSTERED INDEX also. I also notice that the primary key on the
table
> air_itin_price is a composite index on air_itin_id + psgr_type. But the qu
ery
> is only for air_itin_id. Does that make a difference?
> Any pointers will be appreciated.
some more info from trace:=
Deadlock encountered ... Printing deadlock information
2004-03-19 14:12:34.65 spid4
2004-03-19 14:12:34.65 spid4 Wait-for graph
2004-03-19 14:12:34.65 spid4
2004-03-19 14:12:34.65 spid4 Node:1
2004-03-19 14:12:34.65 spid4 PAG: 6:1:3120 CleanCnt:1 M
ode: S Flags: 0x2
2004-03-19 14:12:34.65 spid4 Grant List 0::
2004-03-19 14:12:34.65 spid4 Owner:0x42bcba80 Mode: S Flg:0x0
Ref:1 Life:00000000
SPID:178 ECID:0
2004-03-19 14:12:34.65 spid4 SPID: 178 ECID: 0 Statement Type: EXECUT
E Line #: 1
2004-03-19 14:12:34.65 spid4 Input Buf: RPC Event: sp_cursorfetch;1
2004-03-19 14:12:34.65 spid4 Requested By:
2004-03-19 14:12:34.65 spid4 ResType:LockOwner Stype:'OR' Mode: IX SP
ID:76 ECID:0
Ec0x713CF510) Value:0x42bd18e0 Cost0/3F0)
2004-03-19 14:12:34.65 spid4
2004-03-19 14:12:34.65 spid4 Node:2
2004-03-19 14:12:34.65 spid4 PAG: 6:1:10267 CleanCnt:1 M
ode: IX Flags: 0x0
2004-03-19 14:12:34.65 spid4 Grant List 2::
2004-03-19 14:12:34.65 spid4 Owner:0x42bd3080 Mode: IX Flg:0x0
Ref:0 Life:02000000
SPID:76 ECID:0
2004-03-19 14:12:34.65 spid4 SPID: 76 ECID: 0 Statement Type: INSERT
Line #: 1
2004-03-19 14:12:34.65 spid4 Input Buf: Language Event: INSERT INTO a
ir_itin_price
(air_itin_id,psgr_type,quantity,pub_fare
,base_fare,q_charge,other_charges,tt
l_markup,ttl_tax,securit
y_fee,fare_tax_rate, us1_tax) VALUES
(398529,0,1,237.24,183.10,0.00,0.00,0.00,44.14,10.00,0.0000,13.74)
2004-03-19 14:12:34.65 spid4 Requested By:
2004-03-19 14:12:34.65 spid4 ResType:LockOwner Stype:'OR' Mode: S SPI
D:178 ECID:0
Ec0x716F1548) Value:0x42bca6c0 Cost0/0)
2004-03-19 14:12:34.65 spid4 Victim Resource Owner:
2004-03-19 14:12:34.65 spid4 ResType:LockOwner Stype:'OR' Mode: S SPID:
178 ECID:0
Ec0x716F1548) Value:0x42bca6c0 Cost0/0)
Looks like it is a conversion deadlock.|||both sessions are using READ COMMITTED.|||"rkusenet" <rkusenet@.sympatico.ca> wrote in message
news:c3fkhh$28a94j$1@.ID-75254.news.uni-berlin.de...
> Version: SQL Server 2000 8.00.818
> Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
> I have been asked to look into a problem in one of the database
> at our client site. I have very little idea of the application.
> It seems they are facing intermittent deadlock problem. This is the
> query of the session which is *always* rolled back.
>
> SELECT air_itin_fare_calc.air_itin_price_id, air_itin_price.air_itin_id,
> ...
> FROM air_itin_price, air_itin_fare_calc
> WHERE air_itin_price.air_itin_id = ?
> AND air_itin_price.air_itin_price_id =
air_itin_fare_calc.air_itin_price_id
> order by air_itin_fare_calc.air_itin_price_id
> The index on the two tables
> ALTER TABLE [dbo].[air_itin_price] WITH NOCHECK ADD
> CONSTRAINT [PK_air_itin_price] PRIMARY KEY CLUSTERED
> (
> [air_itin_id],
> [psgr_type]
> ) WITH FILLFACTOR = 50 ON [PRIMARY]
> CREATE CLUSTERED INDEX [PK_air_itin_price_id] ON
> [dbo].[air_itin_fare_calc]([air_itin_price_id]) ON [PRIMAR
Y]
> CREATE INDEX [air_itin_price_airitinpriceid] ON
> [dbo].[air_itin_price]([air_itin_price_id]) ON [PRIMARY]
> This is a read only query only, even though the isolation level is same
for
> all sessions (SERIALIZABLE).
> Since the columns in the WHERE CLAUSE is indexed, I assume that SQLServer
will
> use key locks only. I am bit concerned about CLUSTERED INDEX. Is the
behavior
> same with CLUSTERED INDEX also. I also notice that the primary key on the
table
> air_itin_price is a composite index on air_itin_id + psgr_type. But the
query
> is only for air_itin_id. Does that make a difference?
>
Perhaps. If the query used the key, then it's locks would be more narrow.
It looks like the row being inserted by one client might belong in the
resultset of for the other client. If the query specified the full key, it
might be clear to SQL that that is not the case.
Also the query is using
sp_cursorfetch;1
What kind of cursor is the client using?
David

Saturday, February 25, 2012

DCOM Error 10005

I have a setup where in following scenario i get DCOM error
1. Install a 32 bit NT service on x64
2. Install SQL 2005 Server
3. Upgrade the 32bit NT service using msi package.
After step 2 the NT service is running fine.
But after step 3,
Service fails to start with Error,
The MyService service failed to start due to the following error:
The service did not respond to the start or control request in a
timely fashion. (event 7000)
Event viewer also shows the DCOM error 10005.
DCOM got error "The service did not respond to the start or control
request in a timely fashion. " attempting to start the service
MyService with arguments "-Service" in order to run the server.
This problem is seen only on setups where i have SQL 2005 installed.
Is there a way to find out why "Service Control Manager" manager gives
errors 7000 & 7009. '
MyService is created using VC6 ATL wizard. It is run in "Local System"
account and in non-interactive mode.
Any help will be greatly appreciated.
Thanks,
wnHi
"wn123456@.gmail.com" wrote:
> I have a setup where in following scenario i get DCOM error
> 1. Install a 32 bit NT service on x64
> 2. Install SQL 2005 Server
> 3. Upgrade the 32bit NT service using msi package.
> After step 2 the NT service is running fine.
> But after step 3,
> Service fails to start with Error,
> The MyService service failed to start due to the following error:
> The service did not respond to the start or control request in a
> timely fashion. (event 7000)
> Event viewer also shows the DCOM error 10005.
> DCOM got error "The service did not respond to the start or control
> request in a timely fashion. " attempting to start the service
> MyService with arguments "-Service" in order to run the server.
> This problem is seen only on setups where i have SQL 2005 installed.
> Is there a way to find out why "Service Control Manager" manager gives
> errors 7000 & 7009. '
> MyService is created using VC6 ATL wizard. It is run in "Local System"
> account and in non-interactive mode.
> Any help will be greatly appreciated.
> Thanks,
> wn
>
You may want to check http://support.microsoft.com/kb/892500 this shows how
to turn on logging so you may get more information.
John|||On Feb 27, 7:23 pm, John Bell <jbellnewspo...@.hotmail.com> wrote:
> Hi
>
>
> "wn123...@.gmail.com" wrote:
> > I have a setup where in following scenario i get DCOM error
> > 1. Install a 32 bit NT service on x64
> > 2. Install SQL 2005 Server
> > 3. Upgrade the 32bit NT service using msi package.
> > After step 2 the NT service is running fine.
> > But after step 3,
> > Service fails to start with Error,
> > The MyService service failed to start due to the following error:
> > The service did not respond to the start or control request in a
> > timely fashion. (event 7000)
> > Event viewer also shows the DCOM error 10005.
> > DCOM got error "The service did not respond to the start or control
> > request in a timely fashion. " attempting to start the service
> > MyService with arguments "-Service" in order to run the server.
> > This problem is seen only on setups where i have SQL 2005 installed.
> > Is there a way to find out why "Service Control Manager" manager gives
> > errors 7000 & 7009. '
> > MyService is created using VC6 ATL wizard. It is run in "Local System"
> > account and in non-interactive mode.
> > Any help will be greatly appreciated.
> > Thanks,
> > wn
> You may want to checkhttp://support.microsoft.com/kb/892500this shows how
> to turn on logging so you may get more information.
> John- Hide quoted text -
> - Show quoted text -
Thanks John.
I tried by adding registry entries mentioned in the KB article. But i
am not getting any additional error events.
Looks like this is not an DCOM related problem.
I have another NT service which is not a COM service that too shows
the same problem.
Do you have any idea if i can enable some logging for "Service control
Manager" ?
The control do not reach to ServiceMain function of MyService.
Is it that "Service control Manager" is returning error ?|||Hi
> Thanks John.
> I tried by adding registry entries mentioned in the KB article. But i
> am not getting any additional error events.
> Looks like this is not an DCOM related problem.
> I have another NT service which is not a COM service that too shows
> the same problem.
> Do you have any idea if i can enable some logging for "Service control
> Manager" ?
> The control do not reach to ServiceMain function of MyService.
> Is it that "Service control Manager" is returning error ?
>
Have you looked in the event log for any messages?
John

DCOM Error 10005

I have a setup where in following scenario i get DCOM error
1. Install a 32 bit NT service on x64
2. Install SQL 2005 Server
3. Upgrade the 32bit NT service using msi package.
After step 2 the NT service is running fine.
But after step 3,
Service fails to start with Error,
The MyService service failed to start due to the following error:
The service did not respond to the start or control request in a
timely fashion. (event 7000)
Event viewer also shows the DCOM error 10005.
DCOM got error "The service did not respond to the start or control
request in a timely fashion. " attempting to start the service
MyService with arguments "-Service" in order to run the server.
This problem is seen only on setups where i have SQL 2005 installed.
Is there a way to find out why "Service Control Manager" manager gives
errors 7000 & 7009. '
MyService is created using VC6 ATL wizard. It is run in "Local System"
account and in non-interactive mode.
Any help will be greatly appreciated.
Thanks,
wnHi
"wn123456@.gmail.com" wrote:

> I have a setup where in following scenario i get DCOM error
> 1. Install a 32 bit NT service on x64
> 2. Install SQL 2005 Server
> 3. Upgrade the 32bit NT service using msi package.
> After step 2 the NT service is running fine.
> But after step 3,
> Service fails to start with Error,
> The MyService service failed to start due to the following error:
> The service did not respond to the start or control request in a
> timely fashion. (event 7000)
> Event viewer also shows the DCOM error 10005.
> DCOM got error "The service did not respond to the start or control
> request in a timely fashion. " attempting to start the service
> MyService with arguments "-Service" in order to run the server.
> This problem is seen only on setups where i have SQL 2005 installed.
> Is there a way to find out why "Service Control Manager" manager gives
> errors 7000 & 7009. '
> MyService is created using VC6 ATL wizard. It is run in "Local System"
> account and in non-interactive mode.
> Any help will be greatly appreciated.
> Thanks,
> wn
>
You may want to check http://support.microsoft.com/kb/892500 this shows how
to turn on logging so you may get more information.
John|||On Feb 27, 7:23 pm, John Bell <jbellnewspo...@.hotmail.com> wrote:
> Hi
>
>
> "wn123...@.gmail.com" wrote:
>
>
>
>
>
>
>
> You may want to checkhttp://support.microsoft.com/kb/892500this shows how
> to turn on logging so you may get more information.
> John- Hide quoted text -
> - Show quoted text -
Thanks John.
I tried by adding registry entries mentioned in the KB article. But i
am not getting any additional error events.
Looks like this is not an DCOM related problem.
I have another NT service which is not a COM service that too shows
the same problem.
Do you have any idea if i can enable some logging for "Service control
Manager" ?
The control do not reach to ServiceMain function of MyService.
Is it that "Service control Manager" is returning error ?|||Hi

> Thanks John.
> I tried by adding registry entries mentioned in the KB article. But i
> am not getting any additional error events.
> Looks like this is not an DCOM related problem.
> I have another NT service which is not a COM service that too shows
> the same problem.
> Do you have any idea if i can enable some logging for "Service control
> Manager" ?
> The control do not reach to ServiceMain function of MyService.
> Is it that "Service control Manager" is returning error ?
>
Have you looked in the event log for any messages?
John

Friday, February 17, 2012

DBNULL is giving me a headach!

Could someone please help with this:
I'm trying to connect to a sql server 2000 that to web service. When i run
the service i get:
System.InvalidCastException: Specified cast is not valid.
at wsStudents.Service1.GetStudent(String studentlastname) in
C:\Inetpub\wwwroot\wsStudents\Service1.asmx.vb:line 82
and a throws a similar error (Cast from type 'DBNull' to type 'String' is
not valid) when i try to consume it. This code accepts one input and one
output paramer. The value returned from the output paramter seems be Nothing
"
!!
Here's the code:
<WebMethod()> _
Public Function GetStudent(ByVal studentlastname As String) As String
Dim dsResult As New DataSet
Dim strSQL As String
Dim result_outParam As String
'strSQL = "SELECT @.StuFee FROM dbo.Student WHERE
dbo.Student.LastName = @.StuLName and dbo.Student.FirstName =@.StuFName"
strSQL = "SELECT @.StuFee FROM dbo.Student WHERE dbo.Student.LastName
= @.StuLName"
Dim cmd As New SqlCommand(strSQL, conn)
'Add the first input paramter
cmd.Parameters.Add("@.StuLName", SqlDbType.VarChar)
cmd.Parameters("@.StuLName").Direction = ParameterDirection.Input
cmd.Parameters("@.StuLName").Value = studentlastname
'Add the output paramter
cmd.Parameters.Add("@.StuFee", SqlDbType.VarChar, 50)
cmd.Parameters("@.StuFee").Direction = ParameterDirection.Output
If cmd.Connection.State <> ConnectionState.Open Then
conn.Open()
End If
cmd.ExecuteNonQuery()
result_outParam = cmd.Parameters("@.StuFee").Value
Return result_outParam
conn.Close()
I tried to rewrite the last code like this:
result_outParam =
System.DBNull.Value.ToString(cmd.Parameters("@.StuFee").Value)
but no luck
UKok, that is not possible if the value returned is DBNull.
result_outParam = cmd.Parameters("@.StuFee").Value == DBNull.Value ?
string.Empty : cmd.Parameters("@.StuFee").Value.ToString();
This is the long way :-)
HTH, Jens Suessmeyer.|||Thanks Jens
This suggested code i assume is in C# (mine was in vb .net). I'm not
familiar with using "?" symbol. Can you please translate this into VB .net.
Thanks. Execuse my ignorance.
Is this suggested code one line or two lines:
result_outParam = cmd.Parameters("@.StuFee").Value == DBNull.Value ?
string.Empty : cmd.Parameters("@.StuFee").Value.ToString()
UK
"Jens" wrote:

> ok, that is not possible if the value returned is DBNull.
> result_outParam = cmd.Parameters("@.StuFee").Value == DBNull.Value ?
> string.Empty : cmd.Parameters("@.StuFee").Value.ToString();
> This is the long way :-)
> HTH, Jens Suessmeyer.
>|||Nab (Nab@.discussions.microsoft.com) writes:
> This suggested code i assume is in C# (mine was in vb .net). I'm not
> familiar with using "?" symbol. Can you please translate this into VB
> .net.
?: is the C# equivalent of the Iif function in Visual Basic. That is
condition ? true-return : false-return
So Jens's example would read:
result_outParam = Iif(cmd.Parameters("@.StuFee").Value == DBNull.Value, _
string.Empty, _
cmd.Parameters("@.StuFee").Value.ToString())
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thanks. i'll try this and let you know. What I don't understand is that
sometime ago i wrote similar code but never had to to deal with an issue lik
e
this.
I had deleted SQL Servre 2000 since and re-installed it again but never
installed any service packs this time. Could this have something to do with
it?
"Erland Sommarskog" wrote:

> Nab (Nab@.discussions.microsoft.com) writes:
> ?: is the C# equivalent of the Iif function in Visual Basic. That is
> condition ? true-return : false-return
> So Jens's example would read:
> result_outParam = Iif(cmd.Parameters("@.StuFee").Value == DBNull.Value,
_
> string.Empty, _
> cmd.Parameters("@.StuFee").Value.ToString())
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx
>|||
"Erland Sommarskog" wrote:

> Nab (Nab@.discussions.microsoft.com) writes:
> ?: is the C# equivalent of the Iif function in Visual Basic. That is
> condition ? true-return : false-return
> So Jens's example would read:
> result_outParam = Iif(cmd.Parameters("@.StuFee").Value == DBNull.Value,
_
> string.Empty, _
> cmd.Parameters("@.StuFee").Value.ToString())
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx
>|||In addition to what others have posted...
I encounter this often enough that I created a function that I call whenever
I retrieve a value from the database in VB. It saves the time of having to
write an IF statement every time you need to retrieve a value from the
database.
After you have the function your code would read:
result_outParam = nvl(cmd.Parameters("@.StuFee").Value)
Public Shared Function nvl(ByVal strValue As Object) As String
'***************************************
********************************
' Public method
' returns empty strign in place of DB nulls
' prevents errors caused by type discrepencies
'***************************************
********************************
If strValue Is DBNull.Value Then
Return ""
Else
Return strValue
End If
End Function
"Nab" <Nab@.discussions.microsoft.com> wrote in message
news:AC678A4A-BE76-4884-AA65-8D1BFB3697CB@.microsoft.com...
> Could someone please help with this:
>
> I'm trying to connect to a sql server 2000 that to web service. When i
run
> the service i get:
> System.InvalidCastException: Specified cast is not valid.
> at wsStudents.Service1.GetStudent(String studentlastname) in
> C:\Inetpub\wwwroot\wsStudents\Service1.asmx.vb:line 82
> and a throws a similar error (Cast from type 'DBNull' to type 'String' is
> not valid) when i try to consume it. This code accepts one input and one
> output paramer. The value returned from the output paramter seems be
Nothing"
> !!
> Here's the code:
> <WebMethod()> _
> Public Function GetStudent(ByVal studentlastname As String) As String
> Dim dsResult As New DataSet
> Dim strSQL As String
> Dim result_outParam As String
> 'strSQL = "SELECT @.StuFee FROM dbo.Student WHERE
> dbo.Student.LastName = @.StuLName and dbo.Student.FirstName =@.StuFName"
> strSQL = "SELECT @.StuFee FROM dbo.Student WHERE
dbo.Student.LastName
> = @.StuLName"
> Dim cmd As New SqlCommand(strSQL, conn)
> 'Add the first input paramter
> cmd.Parameters.Add("@.StuLName", SqlDbType.VarChar)
> cmd.Parameters("@.StuLName").Direction = ParameterDirection.Input
> cmd.Parameters("@.StuLName").Value = studentlastname
> 'Add the output paramter
> cmd.Parameters.Add("@.StuFee", SqlDbType.VarChar, 50)
> cmd.Parameters("@.StuFee").Direction = ParameterDirection.Output
> If cmd.Connection.State <> ConnectionState.Open Then
> conn.Open()
> End If
> cmd.ExecuteNonQuery()
> result_outParam = cmd.Parameters("@.StuFee").Value
> Return result_outParam
> conn.Close()
> I tried to rewrite the last code like this:
> result_outParam =
> System.DBNull.Value.ToString(cmd.Parameters("@.StuFee").Value)
> but no luck
> --
> UK|||Nab (Nab@.discussions.microsoft.com) writes:
> Thanks. i'll try this and let you know. What I don't understand is that
> sometime ago i wrote similar code but never had to to deal with an issue
> like this.
> I had deleted SQL Servre 2000 since and re-installed it again but never
> installed any service packs this time. Could this have something to do
> with it?
The installation of SQL 2000 cannot affect ADO .Net or VB .Net, as they
are separate products. Maybe you didn't have to deal with any NULL values
the first time?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thanks for all your replies. Jim's function-based code seems to have worked
better for me!
Cheers.
--
UK
"Jim Underwood" wrote:

> In addition to what others have posted...
> I encounter this often enough that I created a function that I call whenev
er
> I retrieve a value from the database in VB. It saves the time of having t
o
> write an IF statement every time you need to retrieve a value from the
> database.
> After you have the function your code would read:
> result_outParam = nvl(cmd.Parameters("@.StuFee").Value)
> Public Shared Function nvl(ByVal strValue As Object) As String
> '***************************************
********************************
> ' Public method
> ' returns empty strign in place of DB nulls
> ' prevents errors caused by type discrepencies
> '***************************************
********************************
> If strValue Is DBNull.Value Then
> Return ""
> Else
> Return strValue
> End If
> End Function
>
> "Nab" <Nab@.discussions.microsoft.com> wrote in message
> news:AC678A4A-BE76-4884-AA65-8D1BFB3697CB@.microsoft.com...
> run
> Nothing"
> dbo.Student.LastName
>
>|||Apologies. In fact, all suggested solutions worked fine now. Thanks to all.
--
UK
"Jim Underwood" wrote:

> In addition to what others have posted...
> I encounter this often enough that I created a function that I call whenev
er
> I retrieve a value from the database in VB. It saves the time of having t
o
> write an IF statement every time you need to retrieve a value from the
> database.
> After you have the function your code would read:
> result_outParam = nvl(cmd.Parameters("@.StuFee").Value)
> Public Shared Function nvl(ByVal strValue As Object) As String
> '***************************************
********************************
> ' Public method
> ' returns empty strign in place of DB nulls
> ' prevents errors caused by type discrepencies
> '***************************************
********************************
> If strValue Is DBNull.Value Then
> Return ""
> Else
> Return strValue
> End If
> End Function
>
> "Nab" <Nab@.discussions.microsoft.com> wrote in message
> news:AC678A4A-BE76-4884-AA65-8D1BFB3697CB@.microsoft.com...
> run
> Nothing"
> dbo.Student.LastName
>
>

dbnull

Is there an easy way in Reporting service to handle dbull in dataset?

I am using the local mode of the new reportviewer control, when I feed the dataset to the report, if there are some dbull column, an exception will be thrown.

To those string column, I can set NULLVALUE property to empty, but to other datatype, like integer, datetime, money, what should I do?

ThanksDBNull is translated to a unitialized object in the report. You can use IsNothing, i.e. IsNothing(Fields!Foo.Value).|||Hey, you know what, it is very strange.

If I use BindingDatasource.datasource = ds.tables(0), (BindDatasource is bound to ReportViewer), I will have exception if any field is null.

But if I use
BindingDatasource.datasource = ds
BindingDatasource.datamember = "Table1"

I don't get exception any more.

Don't why, but it works like charm.

Wei|||

If this solves your problem, please mark the question answered. Thanks. :)

|||In addition to =IsNothing(Fields!Foo.Value), you could use the IS keyword: (Fields!Foo.Value is Nothing)

-- Robert

DBMail permission error

I am using DBMail to send an email notification at the completion of service broker process and have been getting the following security error:

Msg 229, Level 14, State 5, Procedure sp_send_dbmail, Line 1

EXECUTE permission denied on object 'sp_send_dbmail', database 'msdb', schema 'dbo'.

I have given the userID used to run the Service Broker, databasemailuserrole in msdb as per instruction in the msdb. I have also given it execute permission on the sp_send_dbmail but keep getting the error. The service broker is run using a sql login and the dbmail profile is set as public profile. Any suggestions would be much appreciated.

One thing you can do to find additional information on this error is to connect SQL Profiler and run a trace while redoing these steps. When you'll get the permission failure in the trace, you should find additional information telling you what the execution context was at that time. This should help you determine if you have granted EXECUTE permission to the proper principal. If things look as you expected in the trace, take a look at the catalogs as well, to see what permissions are granted on sp_send_mail.

Thanks
Laurentiu

|||

By 'service broker process' I assume you mean an activate procedure. In this case what happens is that you are hitting the 'Extending Database Impersonation under EXECUTE AS context' issue. See this blog entry at http://blogs.msdn.com/remusrusanu/archive/2006/01/12/512085.aspx

The solution is to either sign the activated procedure or mark the database as trustworthy.

HTH,
~ Remus

|||

Remus,

For test purposes, I assign guest to DatabaseMailUserRole in the msdb and I was able to receive the email successfully.

Can you clarify on your blog statement: "sign the procedure with a server level certificate that has the proper rights needed for the operation in question".

What I did were as follows:

1. create certificate with AUTHORIZATION of the user ID that has sysadmin server role (for testing purpose) in the database of the activated sproc

2. add signature to the activated sproc using the newly created certificate

3. add user ID from #1 to msdb and assign DatabaseMailuserRole role

When I run the service broker job, it still resulted in the permission error. Do I miss any steps ?

Many Thanks,

Welly

|||

You have not granted permissions to the certificate. Here's an example that shows how to sign a stored procedure and how to assign permissions to the signing certificate:

http://blogs.msdn.com/lcris/archive/2005/06/15/429631.aspx

The owner (who you specified in the AUTHORIZATION clause) does not matter for signing purposes. In your scenario, you would need to grant EXECUTE on sp_send_dbmail.

Thanks
Laurentiu