Showing posts with label messages. Show all posts
Showing posts with label messages. Show all posts

Monday, March 12, 2012

How to return a string from a Stored Procedure

Up till now I've used SP's for updates and only ever needed to return error messages.

Now I have an SP that checks and validates something and has to return a string containing the result, (always a string/varchar!)

It works fine in Query Analyzer, I just need a demo of how to incorporate it into a VB app.

Hope that makes sense.

Thanks
Markuse OUTPUT Parameters...check BOL for more info..

hth|||Thanks, I already have that.

My question was how to return it into VB.Net|||if you mean how to catch the returned value from vb.net


...
'output parameter
myParam = mycommand.CreateParameter()
myParam.ParameterName = "@.result"
myParam.Direction = ParameterDirection.Output
myParam.SqlDbType = SqlDbType.varchar
mycommand.Parameters.Add(myParam)

mycommand.ExecuteNonQuery()
return convert.todouble((mycommand.Parameters("@.result").Value))
objcon.close
...

hth|||OK, I got what I wanted.

I hadn't thought of using ExecuteScalar with a SP, just needed to broaden my thinking a bit.

so...abbreviated...here's what I did.

Dim con as New SqlConnection("myConnectionString")
Dim cmd = New SqlCommand("mySPname",con)
cmd.CommandType=CommandType.StoredProcedure
cmd.Parameters.Add("@.ItemID",12345)
" " "
" " "
Try
cmd.Connection = con
cmd.Connection.Open()
x = cmd.ExecuteScalar()
Catch exp As SqlException
x = exp.Message
Finally
cmd.Collnection.Close()
End Try

This way I either get the string value I was looking for or the error message.

Friday, March 9, 2012

How to Retry Failed Messages with Database Mail

I am using Database Mail on SQL 2005 SP 2. I can query to find message that
were not able to be sent with the query below.
USE msdb
SELECT *
FROM sysmail_faileditems
How can I retry sending these messages?
Hi Jeremy,
I understand that you would like to resend those unsent emails which are
existed in the view of sysmail_faileditems.
If I have misunderstood, please let me know.
Unfortunately SQL Server 2005 does not provide the feature to resend the
failed messages. You need to send a new mail with the same content of the
previous message. Thinking about Outlook, if a messsage was undelivered,
you can receive a response and then if you want to retry sending the
message, you need to compose a new message. Those failed messages might be
thrown or put into another queue of the mail server and they are not
exposed to the clients.
Appreciate your understanding that this is by design and please feel free
to let us know if you have any other questions or concerns. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

How to Retry Failed Messages with Database Mail

I am using Database Mail on SQL 2005 SP 2. I can query to find message that
were not able to be sent with the query below.
USE msdb
SELECT *
FROM sysmail_faileditems
How can I retry sending these messages?Hi Jeremy,
I understand that you would like to resend those unsent emails which are
existed in the view of sysmail_faileditems.
If I have misunderstood, please let me know.
Unfortunately SQL Server 2005 does not provide the feature to resend the
failed messages. You need to send a new mail with the same content of the
previous message. Thinking about Outlook, if a messsage was undelivered,
you can receive a response and then if you want to retry sending the
message, you need to compose a new message. Those failed messages might be
thrown or put into another queue of the mail server and they are not
exposed to the clients.
Appreciate your understanding that this is by design and please feel free
to let us know if you have any other questions or concerns. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
======================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================

How to Retry Failed Messages with Database Mail

I am using Database Mail on SQL 2005 SP 2. I can query to find message that
were not able to be sent with the query below.
USE msdb
SELECT *
FROM sysmail_faileditems
How can I retry sending these messages?Hi Jeremy,
I understand that you would like to resend those unsent emails which are
existed in the view of sysmail_faileditems.
If I have misunderstood, please let me know.
Unfortunately SQL Server 2005 does not provide the feature to resend the
failed messages. You need to send a new mail with the same content of the
previous message. Thinking about Outlook, if a messsage was undelivered,
you can receive a response and then if you want to retry sending the
message, you need to compose a new message. Those failed messages might be
thrown or put into another queue of the mail server and they are not
exposed to the clients.
Appreciate your understanding that this is by design and please feel free
to let us know if you have any other questions or concerns. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
========================================
=============
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...t/default.aspx.
========================================
==============
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
========================================
==============
This posting is provided "AS IS" with no warranties, and confers no rights.
========================================
==============

Sunday, February 19, 2012

How to restore system messages to master.dbo.sysmessages

Hi,
I suspect that after a blackout here at the office (time enough to loose the
UPS's) I have lost some messages from the sysmessages table in the master
database.
I have discovered this when trying to construct a snapshot replication in
one server, and discovering, after diving into SP code for hours, that the
SP that configure the replication uses some messages to name the job step of
the agents that perform replication, and also discovering that the messages
are not in my database.
So, what can I do?. Do I have to perform a restore of the master database?.
What happen if I have the replication active in the server?.
Thanks
Flix DurnDo you happen to have another SQL Server with similar setup? If so, you
could copy the messages across. Look up sp_addmessage in Books Online too.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Felix D." <Felix.Duran@.segundamano.es> wrote in message
news:eRvxjbS2DHA.2032@.TK2MSFTNGP09.phx.gbl...
Hi,
I suspect that after a blackout here at the office (time enough to loose the
UPS's) I have lost some messages from the sysmessages table in the master
database.
I have discovered this when trying to construct a snapshot replication in
one server, and discovering, after diving into SP code for hours, that the
SP that configure the replication uses some messages to name the job step of
the agents that perform replication, and also discovering that the messages
are not in my database.
So, what can I do?. Do I have to perform a restore of the master database?.
What happen if I have the replication active in the server?.
Thanks
Flix Durn

How to restore system messages to master.dbo.sysmessages

Hi,
I suspect that after a blackout here at the office (time enough to loose the
UPS's) I have lost some messages from the sysmessages table in the master
database.
I have discovered this when trying to construct a snapshot replication in
one server, and discovering, after diving into SP code for hours, that the
SP that configure the replication uses some messages to name the job step of
the agents that perform replication, and also discovering that the messages
are not in my database.
So, what can I do?. Do I have to perform a restore of the master database?.
What happen if I have the replication active in the server?.
Thanks
Félix DuránDo you happen to have another SQL Server with similar setup? If so, you
could copy the messages across. Look up sp_addmessage in Books Online too.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Felix D." <Felix.Duran@.segundamano.es> wrote in message
news:eRvxjbS2DHA.2032@.TK2MSFTNGP09.phx.gbl...
Hi,
I suspect that after a blackout here at the office (time enough to loose the
UPS's) I have lost some messages from the sysmessages table in the master
database.
I have discovered this when trying to construct a snapshot replication in
one server, and discovering, after diving into SP code for hours, that the
SP that configure the replication uses some messages to name the job step of
the agents that perform replication, and also discovering that the messages
are not in my database.
So, what can I do?. Do I have to perform a restore of the master database?.
What happen if I have the replication active in the server?.
Thanks
Félix Durán