Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unhappy Unanswered: upload file to sql server

    I got some problem in uploading file into the sql server used ASP.
    There is no error occur but the file can't be upload into the database.

    This is the connection to the sql server:
    function GetConnection()
    dim Conn
    Conn.Provider = "SQLOLEDB"
    Conn.Open "Server=(Local);Database=userinfo", "sa", "sa"
    set GetConnection = Conn
    end function

    function CreateUploadTable(Conn)
    dim SQL
    SQL = SQL & "CREATE TABLE Upload ("
    SQL = SQL & " UploadID int IDENTITY (1, 1) NOT NULL ,"
    SQL = SQL & " UploadDT datetime NULL ,"
    SQL = SQL & " RemoteIP char (15) NULL ,"
    SQL = SQL & " ContentType char (64) NULL ,"
    SQL = SQL & " SouceFileName varchar (255) NULL ,"
    SQL = SQL & " Title varchar (255) NULL ,"
    SQL = SQL & " Description text NULL ,"
    SQL = SQL & " Data image NULL "
    SQL = SQL & ")"
    Conn.Execute SQL
    end function

    function DBSaveUpload(Fields)
    dim Conn, RS
    Set Conn = GetConnection

    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open "Upload", Conn, 2, 2
    RS.AddNew
    RS("UploadDT") = Now()
    RS("RemoteIP") = Request.ServerVariables("REMOTE_ADDR")
    RS("ContentType") = Fields("DBFile").ContentType
    RS("SouceFileName") = Fields("DBFile").FileName
    RS("DataSize") = Fields("DBFile").Value.Length

    RS("Description") = Fields("Description").Value.String
    RS("Title") = Fields("Title").Value.String
    if IncludeType=1 then'For ScriptUtilities
    RS("Data").AppendChunk Fields("DBFile").Value.ByteArray
    Else'For PureASP upload - String is implemented as method.
    RS("Data").AppendChunk MultiByteToBinary(Fields("DBFile").Value.ByteArray )
    End If

    RS.Update
    RS.Close
    Conn.Close
    DBSaveUpload = "Upload has been successfull"
    end function

    Pls help me!

  2. #2
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    Why don't you use DTS and call the package from ASP to accomplish the task.

    Refer to Books online for DTS functions.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •