结贴率100%
dim length as System.int32
dim upfile as HttpPostedFile
upfile=upload.postedfile
if upfile.ContentLength = 0 Then
lb.text = "Please select a file"
Exit Sub
else
length=upfile.ContentLength
end if
' Create sql connection
dim conn as new sqlconnection(System.Configuration.ConfigurationSettings.AppSettings("dnssql"))
dim cmd as new sqlcommand("iPIC",conn)
cmd.CommandType = CommandType.StoredProcedure
dim filearray() as byte
dim streamobj as stream
try
streamobj=upfile.InputStream
streamobj.read(filearray,0,length)
cmd.Parameters.add ("@Image",SqlDbType.Binary,length).value=filearray
cmd.Parameters.add("@Size",SqlDbType.int,4).Value=length
cmd.Parameters.add("@Date",SqlDbType.DateTime,8).Value=now()
conn.open
cmd.executeNonQuery
catch ex as exception
'throw ex
lb.text=ex.Message.ToString
finally
conn.close
end try
系统提示Value cannot be null. Parameter name: dst
iPIC存储过程为
CREATE PROCEDURE dbo.iPIC
@Image image,
@Size int,
@date DateTime
AS
insert into imagestore (image,size,date) values (@image,@size,@date)
GO
如果没有提取到图片,我该如何判断filearray为空?