????? ???????? ???????? ?? ??? SqlTransaction ? ????? SqlException ????? ??????? ??? ????

?????? ????????? ?????? ?????????
???? ???????: 320142 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

?? ??? ??????

??????

"??? SqlTransaction" ? "??? SqlException" ????? ??????? ?? ".NET Visual Studio ???? ????? ??????? ??????? Console.WriteLine ???? ??? ????.

??? ??? ???? ?? Microsoft Visual Studio .NET ????? ??????? ??? ?????????, ?????? ????????? ??? ?????? ?? ??????? ???????:
??? SqlTransaction
ms-help://MS.MSDNVS/cpref/html/frlrfsystemdatasqlclientsqltransactionclasstopic.htm

??? SqlException
ms-help://MS.MSDNVS/cpref/html/frlrfsystemdatasqlclientsqltransactionclasstopic.htm
??? ????? ??? ?????? ????????? ?? ".NET Visual Studio ?? ????? ??? ????? ???? ????? Microsoft (MSDN) ??????:
??? SqlTransaction
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqltransaction(VS.71).aspx

??? SqlException
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlexception(VS.71).aspx

??????? ????

??? SqlTransaction

???? ???????? ???????? ?????? ??? ???? ?? "??? SqlTransaction" ??????? ?????:
Console.WriteLine("Error: {1}", e.Message)
Console.WriteLine("Error reported by {1}.", e.Source)
				
??? ??????? ??????? Console.WriteLine ?? ????? ????? ??? ?? ???? ?????? ??????? ???????? ??? 0, ?? 1 ????? ???. ???? ????? ????? ??????? ??? ????? ????????? ???????? ?? ????? "???????"SqlTransation ???":
??? ??????? ??? ????? ?? ????? 'System.FormatException' ??? ?? mscorlib.dll ??????? ??????: ??? ?? ???? ?????? (????? ??? ?????) ???? ?? ?? ????? ????? ???? ?? ??? ????? ???????.
??? ??? ???????? ?????? ?????? ??????? 0 ???? ???? ????? ?????? ???????? ??? 0 ??? ???:
Console.WriteLine("Error: {0}", e.Message)
Console.WriteLine("Error reported by {0}.", e.Source)
				

??? SqlException

??? ?? ???? ?????? ??????? Console.WriteLine ???????? ??? 0, ?? 1 ?????. ???? ????? ????? ??????? ??? ????? ????????? ???????? ?? ????? "???????"SqlException ???":
??? ??????? ??? ????? ?? ????? 'System.FormatException' ?? mscorlib.dll ??????? ??????: ??? ?? ???? ?????? (????? ??? ?????) ???? ?? ?? ????? ????? ???? ?? ??? ????? ???????.
???????? ??? ???? ????? ??????? ?????? ?? ????? "SqlException ???" Visual Studio .NET ??????? ???? ?????:
  • ?????? ????????? ???????? ????? "?????? e ???? SqlException" ?????? ????? "e ????? ???? SqlException". ???? ??? ??? ???? ?????? ??????.
  • ??? ??????? ??? ??????? ??? ??????? ???? ??? ???? ?? ??? ????????? ???????? ??????:
    For i = 0 To myErrors.Errors.Count - 1
    					
  • ????? ???? ???????? ???????? SqlErrorsCollection ? ????????? ???????? ???? ??? ???? ?????? ????? ????? ????? ?? ????? ?? ??? ????????? ???????? ??????:
    myErrors[i].Number
    					
??? ??? ???????? ?????? ????????? ???????? ?? ????? ????? "???????"SqlException ???"????????? ???????? ???????:
Public Sub ThrowSqlException()
   Dim myConnString As String = "user id=sa;password=;database=northwind;server=badserver"

   Dim myConnection As New SqlConnection(myConnString)
   Try
      myConnection.Open()
   Catch e As SqlException
      Dim myErrors As SqlErrorCollection = e.Errors
      Dim f As SqlError
      For Each f In myErrors
         Console.WriteLine("Class: {0}", f.Class)
         Console.WriteLine("Error #{0}: {1} on line {2}.", f.Number, f.Message, f.LineNumber)
         Console.WriteLine("Error reported by {0} while connected to {1}", f.Source, f.Server)
         Console.WriteLine("Neither record was written to database.")
         Console.WriteLine("Errors collection contains:")
         Dim i As Integer
         For i = 0 To myErrors.Count - 1
            Console.WriteLine("Class: {0}", myErrors(i).Class)
            Console.WriteLine("Error #{0}: {1} on line {2}.", myErrors(i).Number, myErrors(i).Message, f.LineNumber)
            Console.WriteLine("Error reported by {0} while connected to {1}", myErrors(i).Source, myErrors(i).Server)
         Next i
      Next f
   End Try
End Sub 'ThrowSqlException   
				

?????

?????? ??? ??????? ??????? ???? ??? ???? ????????? ????????? ??????? ?? "????? ??????? ?? Microsoft:
309544BUG: ????? ??? ????????? BeginTransaction() ?????? ??? ??????? ??????
316667BUG: SqlDataReader ??? ??? ????????? Deadlock ?? SqlClient
310351HOW TO: ??????? ??????? ??? ??? ??? ??? ??????? DataAdapter ? DataSet ?? ADO.NET ? Visual Studio .NET

???????

???? ???????: 320142 - ????? ??? ??????: 29/???? ?????/1435 - ??????: 2.3
????? ???
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
????? ??????: 
kbnosurvey kbarchive kbmt kbvs2002sp1sweep kbbug kbdocerr kbpending kbsqlclient kbsystemdata KB320142 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????320142

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com