Hi all,
I am trying to upload images to my DNN database but can't get it to work. DNN's DAL is confusing me a bit. What am I doing wrong?....
CONTROL-------------------- 'Upload_Image_Control Behind Code 'Read file into a data stream Dim iLength As Integer = CType(inputImage.PostedFile.InputStream.Length, Integer) If iLength = 0 Then Exit Sub 'not a valid file Dim image() As Byte inputImage.PostedFile.InputStream.Read(image, 0, iLength) objImageInfo.Image = image()
DAL----------------------- 'Upload_Image_Control Controller Public Function Image_Add(ByVal objImage As ImageInfo) As Integer Return CType(DataProvider.Instance().Image_Add(objImage.ModuleID, objImage.PortalID, objImage.Title, objImage.Text, objImage.DateAdd, objImage.Image), Integer) End Function
'Upload_Image_Control DataProvider Public MustOverride Function Image_Add(ByVal moduleID As Integer, ByVal portalID As Integer, ByVal title As Long, ByVal text As String, ByVal dateAdd As DateTime, ByVal Image As Byte) As Integer
'Upload_Image_Control SqlDataProvider Public Overrides Function Image_Add(ByVal moduleID As Integer, ByVal portalID As Integer, ByVal title As Long, ByVal text As String, ByVal dateAdd As DateTime, ByVal image As Byte) As Integer Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "Image_Add", moduleID, portalID, title, text, dateAdd, image), Integer) End Function
SQL------------------------ 'Design [ImageID] [bigint] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL , [ModuleID] [int] NOT NULL , [PortalID] [int] NOT NULL , [Title] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [Text] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [DateAdd] [datetime] NOT NULL , [Image] [image] NOT NULL
'Proc CREATE PROCEDURE dbo.Image_Add @ModuleID int, @PortalID int, @Title varchar(100), @Text varchar(8000), @DateAdd datetime, @Image image AS INSERT INTO Image ( [ModuleID], [PortalID], [Title], [Text], [DateAdd], [Image]) VALUES ( @ModuleID, @PortalID, @Title, @Text, @DateAdd, @Image) select SCOPE_IDENTITY() GO
Everything seems right, but the images will not uploading to the DB. I would appreciate any advice, thanks in advance. -a8le
Thuan
|