MKItani
asked on
convert code from vb.net to C#
please convert the below code form vb.net to C#:
If TypeOf e.Errors Is Data.SqlClient.SqlExceptio n Then
Dim sqlerr As SqlException = CType(e.Errors.GetBaseExce ption, SqlException)
Select Case sqlerr.Number
Case 2601
e.Row.RowError = "Record is in System"
End Select
If TypeOf e.Errors Is Data.SqlClient.SqlExceptio
Dim sqlerr As SqlException = CType(e.Errors.GetBaseExce
Select Case sqlerr.Number
Case 2601
e.Row.RowError = "Record is in System"
End Select
private void daWaitingList_OnRowUpdated (object send, SqlRowUpdatedEventArgs e)
{
if (e.Status == UpdateStatus.ErrorsOccurre d)
{
try
{
if (e.Errors is System.Data.SqlClient.SqlE xception)
{
SqlException sqlerr = e.Errors.GetBaseException( ) as SqlException;
switch (sqlerr.Number)
{
case 2602:
e.Row.RowError = "Record is in System";
break;
}
}
else
{
e.Row.RowError = e.Errors.Message;
}
}
catch
{
}
}
}
{
if (e.Status == UpdateStatus.ErrorsOccurre
{
try
{
if (e.Errors is System.Data.SqlClient.SqlE
{
SqlException sqlerr = e.Errors.GetBaseException(
switch (sqlerr.Number)
{
case 2602:
e.Row.RowError = "Record is in System";
break;
}
}
else
{
e.Row.RowError = e.Errors.Message;
}
}
catch
{
}
}
}
Btw, in your code you have "Handles daWaitingList.RowUpdated"
in C# you will need to have somewhere in your code to register the daWaitingList.RowUpdated event and supply it the function that I converted.
I assume that you know how to do that.
in C# you will need to have somewhere in your code to register the daWaitingList.RowUpdated event and supply it the function that I converted.
I assume that you know how to do that.
ASKER
Thank you but i don't know how i can register.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Private Sub daWaitingList_OnRowUpdated
If e.Status = UpdateStatus.ErrorsOccurre
Try
If TypeOf e.Errors Is Data.SqlClient.SqlExceptio
Dim sqlerr As SqlException = CType(e.Errors.GetBaseExce
Select Case sqlerr.Number
Case 2601
e.Row.RowError = "Record is in System"
End Select
Else
e.Row.RowError = e.Errors.Message
End If
Catch
End Try