Public Shared Function InsertCustomnews(ByVal title As String, ByVal flddate As String, ByVal _
active As Boolean, ByVal picpath As String, ByVal categoryid As Integer, ByVal value As String, ByVal minitext As String) As Integer
Dim cmd As New SqlCommand("sp_add_customnews", GetConnection)
With cmd.Parameters
.AddWithValue("@fldtitle", title)
.AddWithValue("@flddate", flddate)
.AddWithValue("@fldactive", active)
.AddWithValue("@fldpicpath", picpath)
.AddWithValue("@fldcategoryid", categoryid)
.AddWithValue("@fldminitext", minitext)
.AddWithValue("@fldvalue", value)
End With
Return SqlExecuteInsertSpGetId(cmd)
End Function
Public Shared Function SqlExecuteInsertSpGetId(ByVal cmd As SqlCommand) As Integer
'================================================= ====================
'Execute an Insert Stored Procedure and return the Autonumber field
'================================================= ====================
Dim i As Integer
Dim par As New SqlParameter("@RETURN_VALUE", SqlDbType.Int)
cmd.CommandType = CommandType.StoredProcedure
par.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(par)
Try
i = cmd.ExecuteNonQuery()
Catch ex As Exception
ErrorMessage = "ProDBObject.SqlExecuteInsertSpGetId(SqlComman d): " & ex.Message.ToString
Finally
cmd.Connection.Close()
End Try
Dim parVal As Integer = Convert.ToInt32(par.Value)
Return parVal
End Function