Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...storing an image to database under dnn dalstoring an image to database under dnn dal
Previous
 
Next
New Post
8/6/2006 9:46 PM
 
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
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...storing an image to database under dnn dalstoring an image to database under dnn dal


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out