Public Function test_add(ByVal cxybh As String, ByVal zp As Byte()) As Integer
Dim strsql As String
Try
Dim arParms() As SqlParameter = New SqlParameter(1) {}
arParms(0) = New SqlParameter("@cxybh", System.Data.SqlDbType.NVarChar, 50)
arParms(0).Value = cxybh
arParms(1) = New SqlParameter("@cpic", System.Data.SqlDbType.Image)
arParms(1).Value = zp
Try
SqlHelper.ExecuteNonQuery(GetConn, System.Data.CommandType.Text, "insert into ec_pic(cxybh,cpic) values(@cxybh,@cpic)", arParms)
Catch ex As Exception
End Try
Return 0
Catch ex As Exception
Finally
End Try
End Function
利用存贮过程调用
Public Function savepicbyxybh(ByVal cxybh As String, ByVal cpic As Byte(), ByVal cpicsmall As Byte(), ByVal cpic2 As Byte()) As Boolean
Try
Dim arParms() As SqlParameter = New SqlParameter(3) {}
arParms(0) = New SqlParameter("@pcxybh", System.Data.SqlDbType.NVarChar, 50)
arParms(0).Value = cxybh
arParms(1) = New SqlParameter("@pcpic", System.Data.SqlDbType.Image)
arParms(1).Value = cpic
arParms(2) = New SqlParameter("@pcpicsmall", System.Data.SqlDbType.Image)
arParms(2).Value = cpicsmall
arParms(3) = New SqlParameter("@pcpic2", System.Data.SqlDbType.Image)
arParms(3).Value = cpic2
Try
SqlHelper.ExecuteNonQuery(GetConn, System.Data.CommandType.StoredProcedure, "addcpic", arParms)
Return True
Catch ex As Exception
Return False
End Try
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
存贮过程如下:
CREATE PROCEDURE addcpic
@pcxybh nvarchar(255),
@pcpic image,
@pcpic2 image,
@pcpicsmall image
As
Begin
insert into ec_pic(cxybh,cpic,cpic2,cpicsmall) values(@pcxybh,@pcpic,@pcpic2,@pcpicsmall)
Select @@RowCount
End
GO