Formview - Exception Handling A Sql Server Raised Error On Insert
Dec 2, 2005
I'm trying to get to grips with the formview control and have a problem regarding where an exception is raised if SQL server raises an error when an insert is taking place. I am new to both asp.net & c#
I have put the following code in the SqlDataSource2_Inserted & Formview1_Inserted events as a way of determining where the exception is raised:
if (e.ExceptionHandled){ string exceptionmessage = e.Exception.Message; lblStatus.Text = exceptionmessage;}
These two events are the only one's that have the ExceptionHandled and Exception properties.
I run the code with data that will raise a duplicate key error from SQL Server but the error is not being caught by either of these two handlers. All I get is a page that starts with
Server Error in '/SourceCode' Application.
Violation of UNIQUE KEY constraint 'IX_reftblAntigens'. Cannot insert duplicate key in object 'reftblAntigens'.The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Violation of UNIQUE KEY constraint 'IX_reftblAntigens'. Cannot insert duplicate key in object 'reftblAntigens'.The statement has been terminated....
Is there somewhere else I should be looking to handle this sort of thing? I thought using the databound controls would make life easier but I'm actually finding it more of a pain than coding everything myself.
View 4 Replies
ADVERTISEMENT
Mar 6, 2009
I am trying to handle exceptions using try catch with remote database.
I am writing the following code which works fine if login locally but when I am trying to do the same on linked server its not being caught in try..catch block.
The procedure I am writing to raiserror
create proc CustomError
as
RAISERROR ('db error', 16, 1);
I am calling the above procedure in local database using following code
BEGIN TRY
exec CustomError
END TRY
BEGIN CATCH
select ERROR_MESSAGE() as ERROR_MESSAGE;
END CATCH;
GO
and it works perfectly. I am able to catch the error in catch block.
and i m getting the following result
db error
but when i am trying to do the same on linked server the code doesn't take me to catch block. I am getting following error while executing the code
go
BEGIN TRY
exec [192.168.0.50].[BM].dbo.CustomError
END TRY
BEGIN CATCH
select ERROR_MESSAGE();
END CATCH;
GO
where [192.168.0.50] is a linked server name and BM is the database name and custom error is my sp which is on remote server.
its giving me following error
Msg 50000, Level 16, State 1, Procedure CustomError, Line 11
db error
View 1 Replies
View Related
May 29, 2007
I'm creating a class that will wrap a SqlException and will offer the developer a way of determining how to proceed in handling the exception by offering a suggestion of retrying, revalidating the data, and/or calling the entire process a no go.
One of the ways i've come up with to accomplish this is by using the severity (SqlException.Class) to assist in making a suggestion to the developer.
I'm hoping to get some feedback from the developers who use this forum if they feel severity is or is not the way to go, and also to offer any other ways of accomplishing that they can come up with.
Thanx
AJ
View 3 Replies
View Related
May 21, 2008
Hi all
I need to create script to insert from table to another with handling error if any like(Duplication,Null values ...etc) to any kind of output
Note: I know DTS, OR SSIS can do that easily but my situation needed as script
Kindly if anyone can help
Thanks in advance, best regards
View 4 Replies
View Related
Dec 2, 2005
I do not understand the error handling of SQL Server here. Any error inbulk insert seems to halt the current T-SQL statement entirely, renderingit impossible to log an error. The first statement below executes asexpected, and were I to replace "print" with something meaningful I coulddo some useful error handling. The second statement just seems to totallybail out after the error, preventing me from doing any useful errorhandling. This is a problem b/c I would like to schedule bulk inserts andneed to be notified if there is a problem.The following can be run in QA to demonstrate:print 'BEFORE TYPICAL ERROR'raiserror('Some Error', 16, 10)if (@@ERROR <> 0) print 'I can catch and log this error - good!' elseprint 'I can not catch and log this error - bad!'print 'AFTER TYPICAL ERROR'goprint 'BEFORE BULK INSERT'Bulk insert Northwind.dbo.ordersfrom 'ThisFileDoesNotExist'if (@@ERROR <> 0) print 'I can catch and log this error - good!' elseprint 'I can not catch and log this error - bad!'print 'AFTER BULK INSERT'goTIA,Dave
View 1 Replies
View Related
Sep 7, 2007
it gives error while calling a sql stored procedure as "INPUT STRING WAS NOT IN A CORRECT FORMAT". I am providing the code here.public void get_issid(string cse_email, string tech_email, string subject, string issue_details, string response, string solv_date, out int issid)
{
// Establish ConnectionSqlConnection oConnection = GetConnection();
// build the commandSqlCommand oCommand = new SqlCommand("get_issid", oConnection);
oCommand.CommandType = CommandType.StoredProcedure;
// ParametersSqlParameter paracse_email = new SqlParameter("@cse_email", SqlDbType.VarChar, 50);
paracse_email.Value =cse_email;
oCommand.Parameters.Add(paracse_email);
SqlParameter paratech_email = new SqlParameter("@tech_email", SqlDbType.VarChar,50);
paratech_email.Value = cse_email;
oCommand.Parameters.Add(paratech_email);SqlParameter parasubject = new SqlParameter("@subject", SqlDbType.VarChar, 50);
parasubject.Value = subject;
oCommand.Parameters.Add(parasubject);SqlParameter paraissue_details = new SqlParameter("@issue_details", SqlDbType.VarChar, 500);
paraissue_details.Value = issue_details;
oCommand.Parameters.Add(paraissue_details);SqlParameter pararesponse = new SqlParameter("@response", SqlDbType.VarChar, 500);
pararesponse.Value = response;
oCommand.Parameters.Add(pararesponse);SqlParameter parasolv_date = new SqlParameter("@solv_date", SqlDbType.DateTime);
parasolv_date.Value = solv_date;
oCommand.Parameters.Add(parasolv_date);SqlParameter paraissid = new SqlParameter("@issid", SqlDbType.Int);paraissid.Direction = ParameterDirection.Output;
oCommand.Parameters.Add(paraissid);
try
{
oConnection.Open();
oCommand.ExecuteNonQuery();issid = int.Parse(paraissid.Value.ToString());
}catch (Exception oException)
{throw oException;
}
finally
{
oConnection.Close();
}
}
the stored procedure is:
create proc [dbo].[get_issid](@tech_email varchar(50), @cse_email varchar(50),@subject varchar(50),@issue_details varchar(500),@response varchar(500),@solv_date datetime, @issid int output)
as
select @issid=tech_response.issue_id from tech_response,issue_details where tech_response.tech_email=@tech_email and tech_response.cse_email=@cse_email and tech_response.subject=@subject and tech_response.issue_details=@issue_details and response=@response and solv_date=@solv_date and tech_response.issue_id=issue_details.issue_id
requested to help in this
View 2 Replies
View Related
Nov 14, 2007
I'm unsure how to handle an SQL Exception correctly when the database is unavailable/offline.
I have my aspx file with the C# code-behind, but all of the SQL stuff is done in a separate code file in the App_Code directory.E.g.
CODE-BEHINDDatabaseModifier.deleteUser(username);
DATABASEMODIFIER.cspublic static void deleteUser(string username){ SqlConnection conn = SqlLogin.SqlConnect; SqlCommand command = new SqlCommand("DELETE FROM <table> WHERE Username = '" + username + "'", conn); conn.Open() command.ExecuteNonQuery(); conn.Close()}
Now, that code works perfectly, however if the database I'm connecting to is offline, an SQLException is thrown and because the SQL is handled in my DatabaseModifier class, I'm not sure how to handle it correctly.If I use a Try/Catch block in my code-behind, it doesn't get thrown because the error occurs in my DatabaseModifier class. If I use a Try/Catch block in my DatabaseModifier class, what can I put in the catch block that will inform the user of the database being offline and/or how can I perform a url redirection?
Any help is greatly appreciated.
View 3 Replies
View Related
Apr 18, 1999
Hi,
Im Nithyananda working on a project with SQL server 6.0
Im having a stored procedure which inserts into a table .
If I violate the primary key constraint on the table , I get a 2627 error.
I would like to replace this error with my own.Could u tell me how to do it?
Im an ORACLE guy and relatively new to SQL server.
Is it possible for me to propogate the same error message to any front end?
In my case ,Im using VC++ as front end.
Could someone also tell me the way of calling a SQL stored procedure from
VC++?
Regards
Nithyananda
View 1 Replies
View Related
Aug 22, 2007
Hi All
I m new to the sqlserver.In Oracle we can handle exceptions like this
declare
name varchar(20);
begin
select ename into name from emp where eno=&eno;
dbms_output.put_line(name);
exception
when no_data_found then
dbms_output.put_line('No Entry');
end;
/
We will get the message No Entry When corrsponding employee number dosent exists.
In Sqlserver how to handle these things.
Specifically my requirement is with select statement(Like above program)
Waiting for valuable suggestions
Baba
View 4 Replies
View Related
Sep 24, 2007
Hello,
I am trying to catch an error, but not able to. I am storing the value of @@Error soon after the statement which I believe would generate error. In order to produce the error I have deliberately used a wrong table name. So, the statement breaks but never comes to my error handling code snippet. Instead, it just throws the SQL server error message and quits. What am I doing wrong here? Here is the code snippet. The actual name of the temporary table is #TEMPO_TABLE, but in order to generate the error I have used #TEMPO_. Since this would surely error out, it should go to the label ROLLITBACK. But is not going to that label. Neither is it printing the error number as per the PRINT statement there. It just throws the SQL error and quits the execution. (Or should it NOT??). The Error that it throws it this:
Server: Msg 208, Level 16, State 1, Procedure FEED_PULL_XX, Line 157
Invalid object name '#TEMPO_'.
Can you please let me know whats going wrong here? Thanks a lot in advance.
INSERT INTO Table1
(
[ITAM_ASSET_EUP_BUS_LINE],
[ITAM_MACHINE_STATUS],
[ITAM_OWNER_ID],
[ITAM_ASSET_ADMIN],
[ITAM_MODEL],
[ITAM_ASSET_NAME],
[ITAMMACHINE_PURPOSE]
)
SELECT
[ITAM_ASSET_EUP_BUS_LINE],
[ITAM_MACHINE_STATUS],
[ITAM_OWNER_ID],
[ITAM_ASSET_ADMIN],
[ITAM_MODEL],
[ITAM_ASSET_NAME],
[ITAMMACHINE_PURPOSE]
FROM
#TEMPO_
SET @ErrNo = @@Error
PRINT '@ErrNo is ' + ltrim(str(@ErrNo)) + '.'
IF @ErrNo <> 0
Begin
PRINT '@ErrNo is ' + ltrim(str(@ErrNo)) + '.'
GOTO ROLLITBACK
End
View 7 Replies
View Related
Jun 17, 2006
I need help please....
I am using exception handling and Transaction handling combined.
The code is written to delete a record from 2 different table.
The purpose of using exception and transaction handling combined is to
make sure that the record is deleted in BOTH table. If there is error
while deleting a record from one of the tables, it will rollback the
database to the original and will stop deleting any record.
However, The Transaction handling is not working. When error occurs
while deleting a record on table A, the code still delete a record from
one table B. The transaction.RollBack() doesn't work. This is my code:
Try
Conn
= New
SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Conn.Open()
Trans = sConn.BeginTransaction
For Each row In GridView1.Rows
Dim sql As String = "SELECT * FROM Member
Using Cmd As New SqlCommand(sql, Conn, Trans)
SqlDataSource1.DeleteParameters("MemberID").DefaultValue =
DropDownListMember.SelectedValue
SqlDataSource1.Delete()
SqlDataSource2.DeleteParameters("CarID").DefaultValue =
DropDownListCar.SelectedValue
SqlDataSource2.Delete()
End Using
End If
Next
sTrans.Commit()
Label1.Text = "deleted."
Catch ex As Exception
If sTrans IsNot Nothing Then
sTrans.Rollback()
End If
Label1.Text = "error"
Return
Finally
If sConn IsNot Nothing Then
sConn.Close()
End If
End Try
soo much thanks in advanced!!!
View 1 Replies
View Related
Jan 31, 2008
Hi guys,
Does any one know how to detect when a SQL transaction has been rolled back in either a windows application or ASP.NET. My Transactions always run but when they are rolled back Visual Basic does not pick up any errors in the 'Try Catch SqlException'. Does any one know a way round this. Sorry for the lack of code. Im writing this post on a friends PC but i wil put up my code as soon as possible. Thanks in advance
Matt
View 4 Replies
View Related
Feb 4, 2008
Hi,
I'm trying to do exception handling in a stored procedure, such as IF (@@ERROR <> 0) execute and insert on to an error log table. I have set the volatile @@ERROR global to a variable, but the proc is still throwing a primary key exception; hence, it's not being trapped. My question is why isn't my exception being handled?
Here's my code, your help is much obliged. (my error proc is below the caller)
CREATE PROCEDURE [dbo].[INSERT_STATS_NO_GROUP_PROC]
@stat_type_id int,
@stat_delimited_file_id smallint,
@time_interval datetime,
@call_volume int,
@Err int OUTPUT
AS
SET @Err = 0
DECLARE @Error int
BEGIN TRANSACTION
INSERT INTO DAILY_SUMMARY_STATISTICS
(
stat_type_id,
stat_delimited_file_id,
ssda_customer_id,
time_interval,
call_volume
)
VALUES
(
@stat_type_id,
@stat_delimited_file_id,
NULL,
@time_interval,
@call_volume
)
SET @Error = @@ERROR
IF(@Error <> 0)
BEGIN
GOTO abort
END
COMMIT TRANSACTION
abort:
ROLLBACK TRANSACTION
EXECUTE SET_ERROR_TO_LOG_PROC @SQLErrorID = @Error,@ObjectName = 'INSERT_STATS_NO_GROUP_PROC'
SET @Err = @Error
/*ERROR PROC*/
CREATE PROCEDURE [dbo].[SET_ERROR_TO_LOG_PROC]
@SQLErrorID int,
@ObjectName varchar(50)
AS
DECLARE @SQLErrDescription varchar(200)
SELECT @SQLErrDescription = description FROM master..sysmessages WHERE error = @SQLErrorID
BEGIN TRANSACTION
INSERT INTO [dbo].[OSAUTOREPORTS_ERROR_LOG]
(
error_id,
error_description,
object_name
)
VALUES
(
@SQLErrorID,
@SQLErrDescription,
@ObjectName
)
COMMIT TRANSACTION
Thanks Russ
View 5 Replies
View Related
May 20, 2008
can I handle exception in SQL functions? how??
I am tring to migrate the Database from Oracle 9i to SQL server 2005 with SSMA which converts function in one procedure and wrapper function because of exception handling in Oracle.
View 11 Replies
View Related
Feb 29, 2008
in my package i'm using a for each loop container in order to process all files in a certain folder. everything works fine but of course when i start the service and there are no files available the package waits. is there a way to simply say skip the for each loop or semething like that?
View 2 Replies
View Related
Mar 18, 2008
I have a cursor that loops through some records.
Upon an exception being caught (i.e. when inserting a record, it violates integrity constraint), I would like to do my normal exception handling routine and then continue with the loop to the next record.
Is this possible? If so, how do I implement this behavior?
Thanks.
View 1 Replies
View Related
May 15, 2002
I am running an environment as below
ADO 2.7
SQL Sever OLE DB Provider
VB 6
SQL Server 6.5 SP 5 A Update
If I run a stored procedure that contains a Print statement or gives a warning. Then any error that occurs after that is ignored. No error state is raised in VB and the Errors collection only contains the print or warning.
Can anyone tell me why?
Thanks
Chris
View 1 Replies
View Related
Dec 4, 1998
SQL Server has stopped a critical task, with the following error log. I have executed the task again and the same symptons occur.
--
EXCEPTION_ACCESS_VIOLATION raised, attempting to create sympton dump
***BEGIN STACK TRACE***
0x0040DC1A in SQLSERVR.EXE, ubfree() + 0x009A
...
...
--
Has anyone any had a simliar experience or have any suggestions for investigation?
Cheers
Jasper
View 1 Replies
View Related
Sep 20, 2006
I'm setting up a routine to do some reindexing. To get the info I need I'm trying to use the new function. The DB I think is causing the problem does pass DBCC CHECKDB. I'm not sure why I'm getting this but can not find anyone else that is getting this same error.
When I run this....
SELECT *
FROM sys.dm_db_index_physical_stats (NULL, NULL, NULL, NULL, 'detailed')
I get this....
Location: qxcntxt.cpp:954
Expression: !"No exceptions should be raised by this code"
SPID: 236
Process ID: 1060
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
If I run only for the DB I think is causing the problem I get this...
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
View 6 Replies
View Related
Mar 19, 2007
I have formview and want to get uniq id from SQL Server 2005 after it inserted.
I think i should put some code in the event of oniteminserted, anybody have sample code
Thanks
Hu
View 1 Replies
View Related
Apr 22, 2008
Hello,I am trying to determine the best way to do the following. For simplicity we have two tables Master and Awards. These share a common pk UFID. Master contains columns (UFID, AccountName...) Awards contains columns (ID, UFID, AwardingAgency, Amount) When a user submits a new award in Formview I would like to populate the UFID automatically so that the user does not have to enter this each time. I am currently using the logged in username to select records for that user only. The value of this username matches Master.AccountName. Since I am hoping to use this same logic across many tables, I would appreciate any suggestions as to how best handle this.Thanks,Ken
View 1 Replies
View Related
Aug 11, 2015
I am new to T-SQL programming. I need to write a main procedures to execute multiple transactions. How could I structure the program so that each transaction will not abort if failed. Instead, the next transaction will keep running. At the very end the procedure will output the error and report them back to the main program in the output parameters. Looking for pseudo code.
View 6 Replies
View Related
May 14, 2007
OLEDB transaction is making difference in my migrated application powerbuilder 10.5 which has new oledb driver which is replaced by MSS driver in previous Powerbuilder version.
1.)I am facing the below error on update/save this was not faced during my previous versino drive MSS in powerbuilder.This is oocure only after the change to oledb driver.
"Row change between retrieve and update.".
in front end of my application the error is poped as
"(STD1007) This row has been modified by another user. Save is canceled! ".
Please help to resolve this error.
View 1 Replies
View Related
Aug 10, 2006
I m trying to INSERT a record to my Consultants table using sqldatasource and formview:
here is my sqldatasource code:
<asp:SqlDataSource ID="sqlDS1" runat="server" ConnectionString="<%$ ConnectionStrings:myDB %>"InsertCommand="INSERT INTO [Consultants] ([firstName],[lastName],[skillCategoryID],[resourceManagerID],[AMgroupID],[skillSet],[statusID],[location],[comments],[profile],[isAvailable],[dateModified],[focusID])
VALUES (@FNAME, @LASTNAME, 1, @RESOURCEMANAGERID, @AMGROUPID, @SKILLSET, @STATUSID, @LOCATION,@COMMENTS,@PROFILE,@ISAVAILABLE,getdate(),1)">
<InsertParameters> <asp:FormParameter FormField="txtFName" Name="FNAME" /> <%--other parameters--%></InsertParameters></asp:SqlDataSource>
now in my formview i have this:<asp:FormView DefaultMode="Insert" ID="FormView1" runat="server" DataSourceID="sqlDS1" DataKeyNames="id">
<table border="0" cellspacing="5" cellpadding="0"><tr> <td class="blacktextbold">First Name:</td> <td class="blacktext"><asp:TextBox ID="txtFName" CssClass="txtfield" Width="200" runat="server" Text="<% #Bind('firstName')%>" /> <asp:RequiredFieldValidator ControlToValidate="txtFName" runat="server" ValidationGroup="gpInsert" ErrorMessage="Required Field" Display="Dynamic" CssClass="redtextsmallbold" /> </td></tr> </table>
THE PROBLEM:no matter what i put the txtFName field its ALWAYS null and i get INSERT error as column firstName cant accept NULLany ideas? ur help would be appreciated
View 4 Replies
View Related
Jul 31, 2007
I have a formview that uses a predefined dataset based on a cross table query. When the formview is in insert mode I need to insert the data into two seperate tables. Essentially I have tblPerson and tblAddress and my formview is capturing username, password, name, address line1, address line 2, etc. I presume I need to use a stored procedure to insert a row into tblPerson and then insert a row intp tblAddress. This is easy enough to do but the tables use RI and tblPerson has an imcremental primary key which needs to be innserted into a foreign key field in my address row. How do I do this? I'm using SQL Server.
View 3 Replies
View Related
Feb 17, 2005
I setup the databse and Visual Web Developer to use
stored procedures when the insert command is used. The
database also uses the field UserName that I pass using a
SessionParameter within the InserParameter block from the
Membership.GetUser.Username from the aspnet_ tables.
My difficulty is when using the "Formview" as the body to
with which to insert (I wanted the design versatility of
FormView) I get an error: "system.formatExpression: Input
string was not in a correct format" when I leave the
textboxes empty and invoke the insert command. I first
assumed that the bound textboxes are not being converted
correctly when left blank, so I used the
ConvertEmptyStringToNull=True, with no success. I then
coupled that with the Type=[correct format] still with
the same error. Alas, my final attempt was to set
defaults in the "ALTER PROCEDURE" within the stored
procedure itself.
Any help would be most appreciated. Thanks.
.
View 2 Replies
View Related
Dec 7, 2005
Dear All,
i have a SqlDataSource with a simple select command(e.g. "select a,b,c from foo"). The insert command is a stored procedure and takes less parameters than there are columns in select statement (e.g. "insertFoo(a char(10))").
When used in combination with form view, i get "Procedure or function insertFoo has too many arguments specified" error.
It seems that form view always posts all columns as parameter collection (breakpoint in formview_inserting event shows this) to insert command.
Am I doing something wrong or is this by design? Is the only solution to manualy tweak parameters in formview_inserting event?
TIA
Jernej
View 2 Replies
View Related
Nov 29, 2007
Hello everyone,
I have a package that should accomplish the following task:
- Loop on all files in a given directory.
- Before proccessing the current file in the Enumerator, it should be moved to a folder called "importing"
- Load the content of the file into a destination DB.
- After a successfull load, the file is moved from the "importing" to the "success" folder.
- If anything went wrong during the load process, the file should be moved from the "importing" to the "error" folder and an e-mail should be sent out to a certain admin account.
What I have done so far:
My control flow looks like this:
Foreach Loop containing the following tasks:
- File System Task: moving the current file from its original path to the "importing" folder
- Data Flow Task1: performing some transformations and insertions into the DB and raw files.
- Data Flow Task2: performing some transformations and insertions into the DB and raw files.
- Data Flow Task3: performing some transformations and final insertions into the DB.
- File System Task: moving the current file from the "importing" to the "success" folder
Question:
I do not know how to catch the event that one of my three Data Flow Tasks has failed and in this case perform two simple tasks, namely...
- File System Task: moving the current file from the "importing" to the "error" folder
- Send Mail Task: sending a configured e-mail message to a ceratin administrator.
Thanks in advance...
Regards,
Samar
View 8 Replies
View Related
Apr 6, 2007
I have a form view that I am using to insert new data into a sql express database and would like to find a way to avoid attempting to insert a record if the key already exists. is there a way to do this with the formview insert command. Everything works great until I try to add a record with an already existing value in the unique key field, then it breaks.
View 1 Replies
View Related
Dec 8, 2006
hi i am running a stored procedure and i want to trap the error of that stored procedure and pass it on the user in the asp.net prog.
my stored procedure are running thru a class library using C#. i tried various options of creating a new sql connnection with out using the classlibrary, but i dont get any errors. the code s
used is as follows Dim conn As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("dbconnection1"))
Dim cmd As New SqlCommand("usp_ImportPlanDetails", conn)
cmd.CommandType = CommandType.StoredProcedure'cmd.Parameters.AddWithValue("@ClientId", Session("ClientId"))
AddHandler conn.InfoMessage, New SqlInfoMessageEventHandler(AddressOf MessageEventHandler)
conn.Close()
Private Sub MessageEventHandler(ByVal sender As System.Object, ByVal e As SqlInfoMessageEventArgs)
Dim strMessage As String
For Each sqle As SqlError In e.Errors
strMessage = "Message:" + sqle.Message + "Number:" + sqle.Number + "Procedure:" + sqle.Procedure + "Server:" + sqle.Server + "Source:" + sqle.Source + "State:" + sqle.State + "Line Number:" + sqle.LineNumber
' strMessage = String.Format("Message: {1}, Number: {2}, Procedure: {3}, Server: {4}, Source: {5}, State: {6}, Line Number: {7}" , new Object[]{sqle.Message, sqle.Number, sqle.Server, sqle.Source, sqle.State, sqle.LineNumber})
'Console.WriteLine(strMessage)
lblErrorMsg.Visible = True
lblErrorMsg.Text = strMessage
and also tried doing this oImportPlan = New ImportPlan(System.Configuration.ConfigurationManager.AppSettings(APPSETTINGS_CONNECTION))
With oImportPlan
Try
.ClientID = Session("ClientId")
' .FileName = strFilePath1
.save()
Catch sqlex1 As SqlException
LogException(sqlex1)
End Try
End With
Catch sqlex As SqlException
LogException(sqlex)
End Try
Catch ex As Exception
lblErrorMsg.Text = "Error: Import Failed" + ex.Message
lblErrorMsg.Visible = True
End Try but have no luck in displaying the errors, My stored procedure has raiseerrors, Please help me out
View 2 Replies
View Related
Apr 26, 2000
How to capture errors occured in stored procedures in case SQL SERVER7?
View 1 Replies
View Related
Apr 4, 2006
Hi I think by virtue of not being able to find reference to this I have my answer however.... You trap an error, check it and know that you are happy with it - it isn't an issue. Is it possible to prevent that specific error (number, message - the lot) being passed to the client so developers don't need to handle the error a second time? Ta db chucks :D
View 9 Replies
View Related
Jan 13, 2008
Hi,
I've the following program structure:
For every record
-- insert into table1
-- insert into table2
....
if I encounter an error in the table1 insert, is there any way (other than using cursors) to continue processing the next record?
Thanks for your help.
Subha Fernando
View 11 Replies
View Related