1. First it executes StoredProcedure<br /> 2. Second it executes simple text<br />
Too many parameters
Public Function saveDetails(ByVal Clientid As Integer, ByVal Conditions As String) As Integer Dim strArr As String() Dim intRecordid As Integer Dim strQuery As String Dim flag As Boolean = False Dim objConn As SqlConnection = getConnection() Dim objCMD As New SqlCommand("usp_saveTNC_save", objConn) Dim sp As SqlParameter strArr = Conditions.Split(",") Dim strArrVal As String = "" Try objCMD.Connection = objConn If objConn.State = ConnectionState.Closed Then objConn.Open() End If For i As Integer = 0 To strArr.Length - 1 'SAVE RECORD IN tbl_TConditions .:[BEGIN]:. objCMD.CommandText = "usp_saveTNC_save" objCMD.CommandType = CommandType.StoredProcedure strArrVal = strArr(i) objCMD.Parameters.AddWithValue("@condition", strArrVal) If flag = False Then sp = New SqlParameter("@id", SqlDbType.Int) sp.Direction = ParameterDirection.Output objCMD.Parameters.Add(sp) flag = True End If objCMD.ExecuteNonQuery() intRecordid = sp.Value.ToString() 'SAVE RECORD IN tbl_TConditions .:[END]:. 'SAVE RECORD IN tbl_TConditions_client .:[BEGIN]:. strQuery = "INSERT INTO tbl_TConditions_client VALUES(" & intRecordid & "," & Clientid & ")" objCMD.CommandText = strQuery.ToString objCMD.CommandType = CommandType.Text objCMD.ExecuteNonQuery() 'SAVE RECORD IN tbl_TConditions_client .:[END]:. Next Return 1 Catch ex As Exception Return -1 Finally objConn.Dispose() objConn.Close() objCMD.Dispose() objCMD = Nothing End Try End Function
objCMD.Parameters.Clear()
Next
Dim sp As SqlParameter
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)