显示标签为“message”的博文。显示所有博文
显示标签为“message”的博文。显示所有博文

2012年3月29日星期四

display a message in store procedure

 helo all..., this is my store procedure. but it can not display message. my friend said it must use output code.
can someone add output code to my store procedure, so it can display message?

ALTER PROCEDURE [bank].[dbo].[pay]
(
@.no_billINT,
@.no_orderint,
@.totalcostmoney,
@.messagevarchar(100)-- make it output parameter in your stored procedure
)
AS

BEGIN TRANSACTION

DECLARE @.balanceAS money

select @.balance = balance
from bank.dbo.bill
where no_bill = @.no_bill

select @.totalcost = totalcost
from games.dbo.totalcost
where no_order = @.no_order

if (@.balance > @.totalcost)
begin
set @.balance = @.balance - @.totalcost

UPDATE bank.dbo.bill
SET
[balance] = @.balance
WHERE [no_bill] = @.no_bill

-- set @.message = 'your have enough balance'
end
else
begin
set @.message ='sorry, your balance not enough'
end

COMMIT TRANSACTION

set nocount off

 
 
pls.., thx 

ALTER PROCEDURE [bank].[dbo].[pay]( @.no_billINT, @.no_orderint, @.totalcostmoney, @.messagevarchar(100)OUTPUT-- make it output parameter in your stored procedure)ASBEGIN TRANSACTION DECLARE @.balanceAS moneyselect @.balance = balancefrom bank.dbo.billwhere no_bill = @.no_billselect @.totalcost = totalcostfrom games.dbo.totalcostwhere no_order = @.no_orderif (@.balance > @.totalcost)beginset @.balance = @.balance - @.totalcostUPDATE bank.dbo.billSET [balance] = @.balanceWHERE [no_bill] = @.no_billset @.message ='your have enough balance'endelsebeginset @.message ='sorry, your balance not enough'end

|||

yes, thx. but when i execute that procedure, it told to insert no_order, no_bill,totalcost, message. i don't want to insert message, i want to insert no_order,no_bill,totalcost, and click ok, so then message automatic display it..

can u add any code ?

thx...

|||

Using the code posted below, I dont see how it could be wanting to "INSERT" or "UPDATE" message. We are setting the parameter @.message after the update statement is completed.
If you are still getting the error then post the current version of the code you are using.

ALTER PROCEDURE [bank].[dbo].[pay]( @.no_billINT, @.no_orderint, @.totalcostmoney, @.messagevarchar(100)OUTPUT-- make it output parameter in your stored procedure)ASBEGIN TRANSACTION DECLARE @.balanceAS money select @.balance = balancefrom bank.dbo.billwhere no_bill = @.no_billselect @.totalcost = totalcostfrom games.dbo.totalcostwhere no_order = @.no_orderif (@.balance > @.totalcost)begin set @.balance = @.balance - @.totalcostUPDATE bank.dbo.billSET [balance] = @.balanceWHERE [no_bill] = @.no_billset @.message ='your have enough balance'end else begin set @.message ='sorry, your balance not enough'endCOMMIT TRANSACTION
|||

yes, your code are right, but when i execute your code, it display:

type direction name value

int in no_bill we insert to this,example:110

int in no_order we insert to this,ex:2

money in totalcost we insert to this, ex 100$

char in/out message ??? if i not insert to this, myerror :Procedure or Function 'pay' expects parameter '@.message', whichwas not supplied.

so i must insert it something, then it can work... but i want to only insert no_bill,no_order,totalcost,so message is display automatic after i insert no_bill,no_order,totalcost.. is there can show automatic message without insert data to message?

thx...

|||

When you define an output parameter in a Stored procedure, you still need to pass a parameter in to the stored procedure. In your case you would pass in an empty string param.

Its not inserting into your DB message it just needs to know what to pass your output param back to.

If you need help with calling the stored procedure, then post that code where you are calling it and we can help you call it properly.

|||

thx .., now i want to call that message from pay.aspx. this is my pay.aspx.vb like:

pay.aspx.vb

Protected Sub Button1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles Button1.Command

Dim sp As String = "pay"
Dim connect As String = ConfigurationManager.AppSettings("ConnectionString")
Dim conn As New SqlConnection(connect)
Dim cm As New SqlCommand(sp, conn)
Dim totalcost As Label = Me.FormView1.FindControl("totallabel")
Dim no As Label = Me.FormView1.FindControl("no_orderlabel")
cm.CommandType = CommandType.StoredProcedure
cm.Parameters.AddWithValue("@.totalcost ", totalcost.Text)
cm.Parameters.AddWithValue("@.no_order ", no.Text)
cm.Parameters.AddWithValue("@.no_bill ", no_bill.Text)
cm.Parameters.AddWithValue("@.message", Label1.Text )

conn.Open()
cm.ExecuteNonQuery() ' do not forget to close Connection
conn.Close()

end sub

that code can work..., but i don't know about to display that message.

if totalcost > balance, show message"sorry, your balance is not enough"

if totalcost<balance, not show message..

pls...

thx...


|||

First change

cm.Parameters.AddWithValue("@.message", Label1.Text )

to

cm.Parameters.Add(New SqlParameter("@.message", SqlDbType.VarChar, 250, ParameterDirection.Output))

Then right after

cm.ExecuteNonQuery() ' do not forget to close Connection

add

Dim message As String - cm.Parameters("@.message").Value

|||

thx, it work.. but not display a message.

so i put label1.text in this, but it still no display a message. this is my code:

Protected Sub Button1_Command(ByVal sender As Object, ByVal e AsSystem.Web.UI.WebControls.CommandEventArgs) Handles Button1.Command

Dim sp As String = "pay"
Dim connect As String = ConfigurationManager.AppSettings("ConnectionString")
Dim conn As New SqlConnection(connect)
Dim cm As New SqlCommand(sp, conn)
Dim totalcost As Label = Me.FormView1.FindControl("totallabel")
Dim no As Label = Me.FormView1.FindControl("no_orderlabel")
cm.CommandType = CommandType.StoredProcedure
cm.Parameters.AddWithValue("@.totalcost ", totalcost.Text)
cm.Parameters.AddWithValue("@.no_order ", no.Text)
cm.Parameters.AddWithValue("@.no_bill ", no_bill.Text)
cm.Parameters.Add(New SqlParameter("@.message", SqlDbType.VarChar, 250, ParameterDirection.Output))

conn.Open()
cm.ExecuteNonQuery() ' do not forget to close Connection

Dim message As String - cm.Parameters("@.message").Value
conn.Close()
label1.text= message

end sub

but the label no show message.. how should i do?

thx...

|||

have you tried debugging and stepping through the code?

|||

yes, i have many try it, but not show a message, maybe i put label1.text in wrong location. can u show that label put in true location?

pls..,thx..

|||

other than changing it to

label1.text = message.tostring()

your code looks correct. When you step through it set a breakpoing on "Dim message as string" so when you step on to conn.close() you can see if message has a value.

|||

i have use breakpoint at row label1.text, it display value text="". it mean not take message from @.message,so empty..

or maybe my store procedure is wrong?

this is my store procedure

ALTER PROCEDURE [bank].[dbo].[paid]
(
@.no_billINT,
@.no_orderint,
@.totalcostmoney,
@.messagevarchar(100) output="a"
)
AS

BEGIN TRANSACTION

DECLARE @.balanceAS money

select @.balance = balance
from bank.dbo.bill
where no_bill = @.no_bill

select @.totalcost = totalcost
from games.dbo.totalcost
where no_order = @.no_order

if (@.balance > @.totalcost)
begin
set @.balance = @.balance - @.totalcost

UPDATE bank.dbo.bill
SET
[balance] = @.balance
WHERE [no_bill] = @.no_bill

-- set @.message = 'your have enough balance'
end
else
begin
set @.message ='sorry, your balance not enough'
end

COMMIT TRANSACTION

but i execute in store procedure, it can display message...
so,which is wrong?
thx 

|||

Here is an article for you on another way to define an output parameter.

http://www.sqlservercentral.com/columnists/kKellenberger/usingparameterswithstoredprocedures.asp

Also you have in your stored procedure one line commented out that sets @.message, and your also trying to set a default value using double quotes.

If you want to set a default value for the parameter then set it inside of your begin transaction statement, and also use single quotes in setting it.

2012年3月25日星期日

Disk I/O Errors Error Number 823

Has anyone come across this message when running SQL 2000 Failover clusters ?

I/O error 2(error not found) detected during write at offset 0x00000016d44000 in file 'K:\MSSQL\Data\Int_DB_2_Data.NDF'..

We got this message yesterday, the RAID Array was OK, the Drive could be written to using test editor directly onto the console. We restarted SQL and all came back OK. SPID 3 is the Signal Handler

Any ideas ?Have you check the SQL Error log? My guess is that you may have a torn page in that database.|||I think you should do a full backup, then use this backup version to restore it on another server and run DBCC CHECKDB or DBCC CHECKFILEGROUP to make sure there is no torn page error like joejcheng mentioned. The Error 823 most likey indicate that there is potential disk problem.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/trblsql/tr_reslsyserr_1_2a0j.asp|||I am chasing a similar problem on HP hardware. Make sure you get a disk consistency check done, as sometimes HP hardware is not good about checking for bad sectors, before writing to them.|||Originally posted by MCrowley
I am chasing a similar problem on HP hardware. Make sure you get a disk consistency check done, as sometimes HP hardware is not good about checking for bad sectors, before writing to them.
Many thanks.

I am running DBCC CHECKDB with ALL_ERRORMSGS , PHYSICAL_ONLY first, then scheduled to run with REPAIR_REBUILD at the weekend.

We are using an HP SAN. I will forward this onto our H/W supplier for info.sql

2012年2月25日星期六

Disabling replication problems

Hello,
When I try to remove/disable replication on a particular
server nothing happens. The message box 'Removing
publishing and distribution components ...' comes up and
just hangs from there on. Does anyone know why this is
happening?
Any help would be greatly appreciated!
Thanks in advance
watch what is going on while you try to disable replication using Profiler.
By chance do you have a remote distributor/publisher?
Do you get any error messages?
Try running sp_who2 while you are disabling replication to see if there is
any locking occurring.
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"Mike S." <anonymous@.discussions.microsoft.com> wrote in message
news:26c3101c46371$95c70940$a601280a@.phx.gbl...
> Hello,
> When I try to remove/disable replication on a particular
> server nothing happens. The message box 'Removing
> publishing and distribution components ...' comes up and
> just hangs from there on. Does anyone know why this is
> happening?
> Any help would be greatly appreciated!
> Thanks in advance
|||Hilary,
Can't wait to see this book hit the shelf. You got one buyer here.
"Hilary Cotter" wrote:

> watch what is going on while you try to disable replication using Profiler.
> By chance do you have a remote distributor/publisher?
> Do you get any error messages?
> Try running sp_who2 while you are disabling replication to see if there is
> any locking occurring.
> --
> Hilary Cotter
> Looking for a book on SQL Server replication?
> http://www.nwsu.com/0974973602.html
>
> "Mike S." <anonymous@.discussions.microsoft.com> wrote in message
> news:26c3101c46371$95c70940$a601280a@.phx.gbl...
>
>

2012年2月24日星期五

disable trigger syntax?

Code Snippet

CREATE PROCEDURE Staff_NoteGroup_insert

(

@.staffID AS int,

@.owner AS int,

@.subject AS varchar(256),

@.message AS varchar(512),

@.date_add AS DateTime

)

AS

BEGIN TRANSACTION SERIALIZABLE

DECLARE @.id as int

SELECT @.id = (SELECT MAX(id) FROM Staff_NoteGroup) + 1

IF @.id IS NULL

SET @.id = 1

INSERT INTO Staff_NoteGroup VALUES(@.id, @.staffID, @.owner, @.subject, GETDATE(), GETDATE())

IF @.@.error <> 0 BEGIN

ROLLBACK

RETURN

END

DISABLE TRIGGER Staff_Note_insert ON DATABASE

INSERT INTO Staff_Note VALUES(1, @.id, @.owner, @.message, @.date_add)

ENABLE TRIGGER Staff_Note_insert ON DATABASE

IF @.@.error <> 0 BEGIN

ROLLBACK

RETURN

END

COMMIT

GO

Below is the error message.

Msg 156, Level 15, State 1, Procedure Staff_NoteGroup_insert, Line 26

Incorrect syntax near the keyword 'TRIGGER'.

Msg 102, Level 15, State 1, Procedure Staff_NoteGroup_insert, Line 28

Incorrect syntax near 'ENABLE'.

Msg 102, Level 15, State 1, Procedure Staff_NoteGroup_insert, Line 33

Incorrect syntax near 'COMMIT'.

Where is the problem?

I'm using sql server 2005

Thanks,

Max

To execute these commands, you will need to put semicolons before disable and enable:

;DISABLE TRIGGER Staff_Note_insert ON DATABASE

INSERT INTO Staff_Note VALUES(1, @.id, @.owner, @.message, @.date_add)

;ENABLE TRIGGER Staff_Note_insert ON DATABASE

This will allow your code to compile. I don't know that this is a good idea, and it seems like you are not using it right (is Staff_Note_insert a database trigger? or is it a trigger on the Staff_Note table? That would be

;DISABLE TRIGGER Staff_Note_insert ON Staff_note)

But why disable it here? There might be a good reason, so I am not saying it is necessarily a bad thing, but at the very least if deserves a comment as to why you are doing this for other readers who might have to maintain this code later Smile

|||

Aah the "ON DATABASE" part is suppose to be "ON Staff_Note", at first I thought I did not use the ON clause correctly, forgot to change it back.

As for the disabling it, The trigger will update Staff_NoteGroup.date_edit column, everytime a new note is added for the same group, and since this procedure is adding a new group which should have at least a single note, the date_edit should be empty.

I will probably remove the trigger later and replace them using procedure, currently adding the note is still using normal SQL, so I need a trigger to update the NoteGroup.

The database is originally an ms access so there is quite a lot of things to change to make use of the server facilities and also to make it safe for multi-user. I still have a lot to learn.

Regards,

Max

|||Just a quick thought on your code, and please keep in mind that this is just my opinion:

I think it may be a better idea to make some sort of check IN the trigger that decides if you want to perform the function the trigger is doing as compared to disabling and re-enabling the trigger every time. I can't say specifically why, but the idea of disabling a trigger on a regular basis makes me uneasy.

Anyway, just my opinion.

dinsdale.
|||

>>I can't say specifically why, but the idea of disabling a trigger on a regular basis makes me uneasy. <<

No doubt!|||

Ah I have not thought about making a check in the trigger.

Why is it bad to disable and enable trigger every time? does it affect performance? data integrity?

This is the first time I use trigger (other than when I'm still a uni student.), so I'm not very experience with the side-effect.

Anyway, that trigger part is now gone, I remove the trigger completely!!, replaced by stored procedure.

My application is adapting to SQL Server quite well.

Regards,

Max

disable trigger syntax?

Code Snippet

CREATE PROCEDURE Staff_NoteGroup_insert

(

@.staffID AS int,

@.owner AS int,

@.subject AS varchar(256),

@.message AS varchar(512),

@.date_add AS DateTime

)

AS

BEGIN TRANSACTION SERIALIZABLE

DECLARE @.id as int

SELECT @.id = (SELECT MAX(id) FROM Staff_NoteGroup) + 1

IF @.id IS NULL

SET @.id = 1

INSERT INTO Staff_NoteGroup VALUES(@.id, @.staffID, @.owner, @.subject, GETDATE(), GETDATE())

IF @.@.error <> 0 BEGIN

ROLLBACK

RETURN

END

DISABLE TRIGGER Staff_Note_insert ON DATABASE

INSERT INTO Staff_Note VALUES(1, @.id, @.owner, @.message, @.date_add)

ENABLE TRIGGER Staff_Note_insert ON DATABASE

IF @.@.error <> 0 BEGIN

ROLLBACK

RETURN

END

COMMIT

GO

Below is the error message.

Msg 156, Level 15, State 1, Procedure Staff_NoteGroup_insert, Line 26

Incorrect syntax near the keyword 'TRIGGER'.

Msg 102, Level 15, State 1, Procedure Staff_NoteGroup_insert, Line 28

Incorrect syntax near 'ENABLE'.

Msg 102, Level 15, State 1, Procedure Staff_NoteGroup_insert, Line 33

Incorrect syntax near 'COMMIT'.

Where is the problem?

I'm using sql server 2005

Thanks,

Max

To execute these commands, you will need to put semicolons before disable and enable:

;DISABLE TRIGGER Staff_Note_insert ON DATABASE

INSERT INTO Staff_Note VALUES(1, @.id, @.owner, @.message, @.date_add)

;ENABLE TRIGGER Staff_Note_insert ON DATABASE

This will allow your code to compile. I don't know that this is a good idea, and it seems like you are not using it right (is Staff_Note_insert a database trigger? or is it a trigger on the Staff_Note table? That would be

;DISABLE TRIGGER Staff_Note_insert ON Staff_note)

But why disable it here? There might be a good reason, so I am not saying it is necessarily a bad thing, but at the very least if deserves a comment as to why you are doing this for other readers who might have to maintain this code later Smile

|||

Aah the "ON DATABASE" part is suppose to be "ON Staff_Note", at first I thought I did not use the ON clause correctly, forgot to change it back.

As for the disabling it, The trigger will update Staff_NoteGroup.date_edit column, everytime a new note is added for the same group, and since this procedure is adding a new group which should have at least a single note, the date_edit should be empty.

I will probably remove the trigger later and replace them using procedure, currently adding the note is still using normal SQL, so I need a trigger to update the NoteGroup.

The database is originally an ms access so there is quite a lot of things to change to make use of the server facilities and also to make it safe for multi-user. I still have a lot to learn.

Regards,

Max

|||Just a quick thought on your code, and please keep in mind that this is just my opinion:

I think it may be a better idea to make some sort of check IN the trigger that decides if you want to perform the function the trigger is doing as compared to disabling and re-enabling the trigger every time. I can't say specifically why, but the idea of disabling a trigger on a regular basis makes me uneasy.

Anyway, just my opinion.

dinsdale.
|||

>>I can't say specifically why, but the idea of disabling a trigger on a regular basis makes me uneasy. <<

No doubt!|||

Ah I have not thought about making a check in the trigger.

Why is it bad to disable and enable trigger every time? does it affect performance? data integrity?

This is the first time I use trigger (other than when I'm still a uni student.), so I'm not very experience with the side-effect.

Anyway, that trigger part is now gone, I remove the trigger completely!!, replaced by stored procedure.

My application is adapting to SQL Server quite well.

Regards,

Max

2012年2月19日星期日

DISABLE TRIGGER

How can i disable a trigger'
Any suggestion appreciated.
Message posted via http://www.webservertalk.comHi
-- to diable all
EXEC sp_MSForEachTable N'ALTER TABLE ? DISABLE TRIGGER ALL'
GO
-- to enable all
EXEC sp_MSForEachTable N'ALTER TABLE ? ENABLE TRIGGER ALL'
Note : sp_MSForEachTable is undocumented ans unsupported
"akej via webservertalk.com" <forum@.nospam.webservertalk.com> wrote in message
news:06352efd0e4e43029b575e79a35d51ca@.SQ
webservertalk.com...
> How can i disable a trigger'
> Any suggestion appreciated.
> --
> Message posted via http://www.webservertalk.com|||So maybe better to drop(disable) and afete create(enable)
Message posted via http://www.webservertalk.com|||No, no need to drop and recreate. Simply use
ALTER TABLE table_name DISABLE TRIGGER trigger_name
Replace names as appropriate. Also, to disable all triggers, as Uri already
suggested, replace trigger_name with ALL keyword.
To enable the trigger again, replace DISABLE with ENABLE.
Regards,
Raj|||What about to disable/enable constraint, foreign key constraint '
Message posted via http://www.webservertalk.com

Disable Server Error Messages to Client App (VB)

Hi people!
Can anyone help me with this one? Using SQL Server 2000 and VB5,
calling a stored procedure from VB code. When a message occurs like:
Server: Msg 515, Level 16, State 2, Procedure Ve_KarticeIsplate, Line
235
Cannot insert the value NULL into column 'konto', table
'ibis.dbo.promkred'; column does not allow nulls. INSERT fails.
The statement has been terminated.
VB freaks out, looses the connection to server and stops the execution.
I want to be either be able to disable this message or to ignore it
from client app (using ADO for connection)...
(Simply to ignore the error)Hi VesnaSA,
Here are two excellent articles on error handling in SQL server:
http://www.sommarskog.se/error-handling-I.html
http://www.sommarskog.se/error-handling-II.html
A lot of reading but it's worth it.
"VesnaSA" <VesnaVujovicSA@.gmail.com> wrote in message
news:1132235726.691296.264240@.g14g2000cwa.googlegroups.com...
> Hi people!
> Can anyone help me with this one? Using SQL Server 2000 and VB5,
> calling a stored procedure from VB code. When a message occurs like:
> Server: Msg 515, Level 16, State 2, Procedure Ve_KarticeIsplate, Line
> 235
> Cannot insert the value NULL into column 'konto', table
> 'ibis.dbo.promkred'; column does not allow nulls. INSERT fails.
> The statement has been terminated.
> VB freaks out, looses the connection to server and stops the execution.
> I want to be either be able to disable this message or to ignore it
> from client app (using ADO for connection)...
> (Simply to ignore the error)
>|||> Cannot insert the value NULL into column 'konto', table
> 'ibis.dbo.promkred'; column does not allow nulls. INSERT fails.
> The statement has been terminated.
> VB freaks out, looses the connection to server and stops the execution.
> I want to be either be able to disable this message or to ignore it
> from client app (using ADO for connection)...
> (Simply to ignore the error)
>
it would be better though not to pass NULL value to this column? or drop the
constraint from database, though i assume that having nulls in konto column
might be somewhat confusing for people working with account related
application
peter|||Thanx but i handle those transactions with errors in another way, by
placing them in another table,
the point is not to prevent it but to disable the message so that the
procedure can go on for the correct
ones and just skip the ones with errors... To prevent VB to loose the
connection when error happens...
But thanx anyway...|||Thanx Reymond, I'll dig into it, it seams that there is no way to
prevent server from sending the message, thw question is now if the
recordset in ADO can be adjusted so it doesn't report the message?|||I'm not a VB programmer but maybe this will help:
(this is script but you can probably adapt it to VB)
ON ERROR RESUME NEXT
--execute your stored procedure Ve_KarticeIsplate here
If you wish, you can view the errors:
If objConn.errors.count > 0 then
Response.write(objConn.errors.count) & " = " &
objConn.errors(0).description
For counter= 0 to objConn.errors.count
Response.write(objConn.errors(counter).number)
Response.write(objConn.errors(counter).description)
Next
end if
If you're still having problems, post in one of the VB newsgroups.
"VesnaSA" <VesnaVujovicSA@.gmail.com> wrote in message
news:1132238362.365549.85690@.z14g2000cwz.googlegroups.com...
> Thanx Reymond, I'll dig into it, it seams that there is no way to
> prevent server from sending the message, thw question is now if the
> recordset in ADO can be adjusted so it doesn't report the message?
>|||shouldn't you do it in the stored procedure then? using db to handle and
send errors might be expensive, and ADO is not best on handling errors.
also, I assume that account number shouldn't be empty and this is a business
rule, so why don't you check it before you call db? this would save you the
problem. exceptions should not be the way you control flow of your program.
Peter
"VesnaSA" <VesnaVujovicSA@.gmail.com> wrote in message
news:1132237902.217152.65360@.g14g2000cwa.googlegroups.com...
> Thanx but i handle those transactions with errors in another way, by
> placing them in another table,
> the point is not to prevent it but to disable the message so that the
> procedure can go on for the correct
> ones and just skip the ones with errors... To prevent VB to loose the
> connection when error happens...
> But thanx anyway...
>|||"Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
news:%23GEb9u46FHA.2716@.TK2MSFTNGP11.phx.gbl...
> shouldn't you do it in the stored procedure then? using db to handle and
> send errors might be expensive, and ADO is not best on handling errors.
> also, I assume that account number shouldn't be empty and this is a
> business rule, so why don't you check it before you call db? this would
> save you the problem. exceptions should not be the way you control flow of
> your program.
> Peter
I agree with you on this one.
Error handling has to be done in the database.
The parameters must be validated client side.
But (I'm sure that you saw the BUT coming) error handling also has to be
done in VB.
Imagine these cases:
-the connexion to the database is lost
-someone changed something in the database
-some unforseen error occors in the SP|||First, resolve the bug in the stored procedure which is trying to insert a
NULL into a non-nullable column.
There are techniques for implementing error handling in T-SQL, but this is
only useful for basic things like rolling back transactions and process
flow. The last line of defense is error handling at the application level,
and based on your description of the "VB freaks out", it sounds like perhaps
there no module or function level handling in the application, and the error
is being escalated up the call stack until becomes unrecoverable.
Handling Errors in Visual Basic
Error Handling Hierarchy
http://msdn.microsoft.com/library/d...nghierarchy.asp
Handling Errors and Messages in ADO
http://msdn.microsoft.com/library/d...
9pr.asp
http://msdn.microsoft.com/library/d...rorhandling.asp
"VesnaSA" <VesnaVujovicSA@.gmail.com> wrote in message
news:1132235726.691296.264240@.g14g2000cwa.googlegroups.com...
> Hi people!
> Can anyone help me with this one? Using SQL Server 2000 and VB5,
> calling a stored procedure from VB code. When a message occurs like:
> Server: Msg 515, Level 16, State 2, Procedure Ve_KarticeIsplate, Line
> 235
> Cannot insert the value NULL into column 'konto', table
> 'ibis.dbo.promkred'; column does not allow nulls. INSERT fails.
> The statement has been terminated.
> VB freaks out, looses the connection to server and stops the execution.
> I want to be either be able to disable this message or to ignore it
> from client app (using ADO for connection)...
> (Simply to ignore the error)
>|||True, it is important to implement T-SQL error handling so that the
transaction is rolled back, but any advanced error handling like retry logic
or logging errors is best implemented at the application level.
"Raymond D'Anjou" <rdanjou@.canatradeNOSPAM.com> wrote in message
news:e2XAz%2346FHA.3660@.TK2MSFTNGP09.phx.gbl...
> "Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
> news:%23GEb9u46FHA.2716@.TK2MSFTNGP11.phx.gbl...
> I agree with you on this one.
> Error handling has to be done in the database.
> The parameters must be validated client side.
> But (I'm sure that you saw the BUT coming) error handling also has to be
> done in VB.
> Imagine these cases:
> -the connexion to the database is lost
> -someone changed something in the database
> -some unforseen error occors in the SP
>