If you have only one or two table parameters, you do not need to iterate over all parameters. Instead, I wrote a function and passed this parameter to this function so that it corrects the file_name.
This is the function:
Private Sub SetTypeNameForTableParameter(ByRef parameter As System.Data.SqlClient.SqlParameter) If parameter.SqlDbType = SqlDbType.Structured Then Dim name As String = parameter.TypeName Dim index As Integer = name.IndexOf(".") If index <> -1 Then name = name.Substring(index + 1) If name.Contains(".") Then parameter.TypeName = name End If End If End If End Sub
This is the part of the code in which I call the database:
'Get Parameters in stored proc Dim cmd As System.Data.Common.DbCommand = db.GetStoredProcCommand("MyStoredProc") db.DiscoverParameters(cmd) 'The first parameter is the return value. Remove it. Dim returnValueParam As Data.Common.DbParameter = cmd.Parameters(0) cmd.Parameters.Remove(returnValueParam) 'Set type name for every table parameter SetTypeNameForTableParameter(cmd.Parameters(1)) 'Assign values to the parameters cmd.Parameters(0).Value = id cmd.Parameters(1).Value = mydatatable 'Execute the command db.ExecuteNonQuery(cmd)
Silvia D.
source share