G
gallian
I am trying to insert new records in table via stored proc
EMP_Calendar_SAVE_sp. There is no exception thorwn but RowsAffected is
-1. I have tested the store proc, it works fine. Any Help?
Code as below:=
Public Sub EMP_Calendar_SAVE_sp(ByVal EmployeeCode As String, ByVal
CalendarType As String, ByVal StartDate As Date, ByVal EndDate As Date)
Dim SelectCommandText As String = "EMP_Calendar_SAVE_sp"
Dim MySqlCommand As New SqlCommand(cmdText:=SelectCommandText,
connection:=MyBase.m_Connection, transaction:=MyBase.m_Transaction)
MySqlCommand.CommandType = CommandType.StoredProcedure
MySqlCommand.Parameters.Add(New SqlParameter("@EmployeeCode",
EmployeeCode))
MySqlCommand.Parameters.Add(New SqlParameter("@CalendarType",
CalendarType))
MySqlCommand.Parameters.Add(New SqlParameter("@StartDate",
StartDate))
MySqlCommand.Parameters.Add(New SqlParameter("@EndDate",
EndDate))
Dim RowsAffected As Integer
Try
RowsAffected = MySqlCommand.ExecuteNonQuery()
Catch ex As Exception
Dim Message As String = "Error calling stored procedure '"
+ SelectCommandText + "'" + Environment.NewLine _
+ "EmployeeCode='" + EmployeeCode +
"'" + Environment.NewLine _
+ "CalenderType='" + CalendarType +
"'" + Environment.NewLine _
+ "StartDate='" + StartDate + "'" +
Environment.NewLine _
+ "EndDate='" + EndDate
Throw New Exception(Message)
End Try
End Sub
EMP_Calendar_SAVE_sp. There is no exception thorwn but RowsAffected is
-1. I have tested the store proc, it works fine. Any Help?
Code as below:=
Public Sub EMP_Calendar_SAVE_sp(ByVal EmployeeCode As String, ByVal
CalendarType As String, ByVal StartDate As Date, ByVal EndDate As Date)
Dim SelectCommandText As String = "EMP_Calendar_SAVE_sp"
Dim MySqlCommand As New SqlCommand(cmdText:=SelectCommandText,
connection:=MyBase.m_Connection, transaction:=MyBase.m_Transaction)
MySqlCommand.CommandType = CommandType.StoredProcedure
MySqlCommand.Parameters.Add(New SqlParameter("@EmployeeCode",
EmployeeCode))
MySqlCommand.Parameters.Add(New SqlParameter("@CalendarType",
CalendarType))
MySqlCommand.Parameters.Add(New SqlParameter("@StartDate",
StartDate))
MySqlCommand.Parameters.Add(New SqlParameter("@EndDate",
EndDate))
Dim RowsAffected As Integer
Try
RowsAffected = MySqlCommand.ExecuteNonQuery()
Catch ex As Exception
Dim Message As String = "Error calling stored procedure '"
+ SelectCommandText + "'" + Environment.NewLine _
+ "EmployeeCode='" + EmployeeCode +
"'" + Environment.NewLine _
+ "CalenderType='" + CalendarType +
"'" + Environment.NewLine _
+ "StartDate='" + StartDate + "'" +
Environment.NewLine _
+ "EndDate='" + EndDate
Throw New Exception(Message)
End Try
End Sub