Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ASP 3.0 : Trying to use with SQL Server 2000 Signup · Login
Author Thread
Trying to use with SQL Server 2000
Posted in tutorial: Uploading Files to the Server Hard Disk using plain ASP
·  markargente
User
Joined: 16 Jul 2007
Total Posts: 1
Trying to use with SQL Server 2000
Posted: 16 Jul 2007
I'm trying to get this to work with SQL Server 2000. I tried using it two different ways. I tried using a recordset and .Update like you did and tried using a stored proc, but I also get an error that way. Any help is appreciated:

STORED PROC WAY:
dim Cn
dim cmd
set Cn = GetConnection()
set cmd = Server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = Cn

cmd.CommandType = adcmdStoredProc
cmd.CommandText = "addFile"

cmd.Parameters.Append cmd.CreateParameter("@itemName", adVarWChar, adParamInput, 50, fileName)
cmd.Parameters.Append cmd.CreateParameter("@itemSize", adInteger, adParamInput, ,fileSize)
cmd.Parameters.Append cmd.CreateParameter("@itemType", adVarWChar, adParamInput, 50, contentType)
cmd.Parameters.Append cmd.CreateParameter("@itemData", adBinary, adParamInput, , fileData)
cmd.Execute
chkErrorHandler Cn, "addFile"

SP: addFile (All permissions are set as needed)
CREATE PROCEDURE [dbo].[addFile]
@itemName as nvarchar(50),
@itemSize as integer,
@itemData as image,
@itemType as nvarchar(50)
AS
IF @itemSize > 0
BEGIN
INSERT INTO TestFileUpload ([ID], [FileName], [FileSize], [ContentType], [FileData])
VALUES (@@identity, @itemName, @itemSize, @itemType, @itemData)
END
GO

Error for Stored Proc Way:
Parameter object is improperly defined. Inconsistent or incomplete information was provided. (Points to last parameter in ASP code)

RECORDSET WAY:
dim Cn
dim cmd
set Cn = GetConnection()
dim rs2
set rs2 = server.CreateObject("ADODB.Recordset")
rs2.Open "TestFileUpload", Cn, 2, 2
rs2.AddNew
rs2("FileName") = fileName
rs2("FileSize") = fileSize
rs2("ContentType") = contentType
rs2("FileData") = fileData
rs2.Update
rs2.Close
set rs2 = nothing
Cn.close
set Cn = Nothing

Table: TestFileUpload
ID: int 4, identity
FileName: varchar 50
FileSize: int 4
ContentType: varchar 50
FileData: image 16


Error:
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. (Points to rs2("FileData")...)
·  Tins30
User
Joined: 1 Aug 2007
Total Posts: 3
Check each OLE DB status value, if available. No work was done
Posted: 1 Aug 2007
I had similar problem. I changed datatype of FileName,
FileSize, ContenType to text from varchar. I am not saying this is possibly a solution. But it worked for me..

This is what I changed it to:

MIMEType text 16 1
ImageData image 16 1
FileName text 16 1
FileSize text text 16 1

Let me know if this works..

See if this works! It worked for me.

Users Who Have Visited This Thread In Last 24 Hours
5 Visitors

Login
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.