upload file into database in asp

Discussion in 'ASP General' started by weiwei, Sep 7, 2004.

  1. weiwei

    weiwei Guest

    Hi All
    I want to upload either image or word document into either access or
    SQL server database
    so far I am doing some small testings and what I can do is upload the
    file from first page and display at the next
    page with (both image or word are working fine).
    however, I cann't insert them into the database, Plus, what type
    should I use in access database?
    anyone who has this type of project, please help me out
    below is my current test code
    <%
    FormSize = Request.TotalBytes
    FormData = Request.BinaryRead( FormSize )
    'bnCRLF = chrB( 13 ) & chrB( 10 )
    'Divider = LEFTB( FormData, INSTRB( FormData, bnCRLF ) - 1 )
    'DataStart = INSTRB( FormData, bnCRLF & bnCRLF ) + 4
    'DataEnd = INSTRB( DataStart + 1, FormData, divider ) - DataStart
    'Response.ContentType = "image/gif"
    'Response.ContentType = "application/msword"
    'Response.BinaryWrite MIDB( FormData, DataStart, DataEnd )
    'Response.BinaryWrite FormData
    %>
    <!--Create and Open the Databse Connection-->
    <% Set connCW = Server.CreateObject("ADODB.Connection") %>
    <% connCW.Open ="Driver={Microsoft Access Driver (*.mdb)}; " &_
    "DBQ=" & Server.Mappath("track.mdb") %>
    <%
    sql = "INSERT INTO upload (FileName) VALUES('" & FormData & "')"
    Set rs = connCW.Execute(sql)
    %>

    I got error saying type mismatch

    thanks in advance
    wei
     
    weiwei, Sep 7, 2004
    #1
    1. Advertising

  2. weiwei

    Roland Hall Guest

    "weiwei" wrote in message
    news:...
    : Hi All
    : I want to upload either image or word document into either access or
    : SQL server database
    : so far I am doing some small testings and what I can do is upload the
    : file from first page and display at the next
    : page with (both image or word are working fine).
    : however, I cann't insert them into the database, Plus, what type
    : should I use in access database?
    : anyone who has this type of project, please help me out
    : below is my current test code
    : <%
    : FormSize = Request.TotalBytes
    : FormData = Request.BinaryRead( FormSize )
    : 'bnCRLF = chrB( 13 ) & chrB( 10 )
    : 'Divider = LEFTB( FormData, INSTRB( FormData, bnCRLF ) - 1 )
    : 'DataStart = INSTRB( FormData, bnCRLF & bnCRLF ) + 4
    : 'DataEnd = INSTRB( DataStart + 1, FormData, divider ) - DataStart
    : 'Response.ContentType = "image/gif"
    : 'Response.ContentType = "application/msword"
    : 'Response.BinaryWrite MIDB( FormData, DataStart, DataEnd )
    : 'Response.BinaryWrite FormData
    : %>
    : <!--Create and Open the Databse Connection-->
    : <% Set connCW = Server.CreateObject("ADODB.Connection") %>
    : <% connCW.Open ="Driver={Microsoft Access Driver (*.mdb)}; " &_
    : "DBQ=" & Server.Mappath("track.mdb") %>
    : <%
    : sql = "INSERT INTO upload (FileName) VALUES('" & FormData & "')"
    : Set rs = connCW.Execute(sql)
    : %>
    :
    : I got error saying type mismatch

    My upload routines upload the file to the server, I move it to a specific
    location and I store the path and filename in the database. I don't see a
    need to store files in databases.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Sep 8, 2004
    #2
    1. Advertising

  3. weiwei

    John Guest

    Roland,

    Do you have a code sample of how you run the doc file download/edit/upload?
    Or is there a link to sample code at MS or elsewhere that you can pass on?
    Or even a general description of the process -- e.g. ... use
    Response.BinaryWrite for ...

    I'm obviously a bit of a beginner at this. I've been looking about the net
    for awhile, likely in the wrong places, and haven't been able to find a good
    model.

    Appreciatively,

    John

    "Roland Hall" <nobody@nowhere> wrote in message
    news:%...
    > "weiwei" wrote in message
    > news:...
    > : Hi All
    > : I want to upload either image or word document into either access or
    > : SQL server database
    > : so far I am doing some small testings and what I can do is upload the
    > : file from first page and display at the next
    > : page with (both image or word are working fine).
    > : however, I cann't insert them into the database, Plus, what type
    > : should I use in access database?
    > : anyone who has this type of project, please help me out
    > : below is my current test code
    > : <%
    > : FormSize = Request.TotalBytes
    > : FormData = Request.BinaryRead( FormSize )
    > : 'bnCRLF = chrB( 13 ) & chrB( 10 )
    > : 'Divider = LEFTB( FormData, INSTRB( FormData, bnCRLF ) - 1 )
    > : 'DataStart = INSTRB( FormData, bnCRLF & bnCRLF ) + 4
    > : 'DataEnd = INSTRB( DataStart + 1, FormData, divider ) - DataStart
    > : 'Response.ContentType = "image/gif"
    > : 'Response.ContentType = "application/msword"
    > : 'Response.BinaryWrite MIDB( FormData, DataStart, DataEnd )
    > : 'Response.BinaryWrite FormData
    > : %>
    > : <!--Create and Open the Databse Connection-->
    > : <% Set connCW = Server.CreateObject("ADODB.Connection") %>
    > : <% connCW.Open ="Driver={Microsoft Access Driver (*.mdb)}; " &_
    > : "DBQ=" & Server.Mappath("track.mdb") %>
    > : <%
    > : sql = "INSERT INTO upload (FileName) VALUES('" & FormData & "')"
    > : Set rs = connCW.Execute(sql)
    > : %>
    > :
    > : I got error saying type mismatch
    >
    > My upload routines upload the file to the server, I move it to a specific
    > location and I store the path and filename in the database. I don't see a
    > need to store files in databases.
    >
    > --
    > Roland Hall
    > /* This information is distributed in the hope that it will be useful, but
    > without any warranty; without even the implied warranty of merchantability
    > or fitness for a particular purpose. */
    > Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    > WSH 5.6 Documentation -

    http://msdn.microsoft.com/downloads/list/webdev.asp
    > MSDN Library - http://msdn.microsoft.com/library/default.asp
    >
    >
     
    John, Sep 8, 2004
    #3
  4. weiwei

    joker Guest

    You may want to check out the following addresses.

    http://www.aspfaq.com/show.asp?id=2149
    http://www.aspfaq.com/show.asp?id=2168
    http://www.aspfaq.com/show.asp?id=2189

    weiwei wrote:

    > Hi All
    > I want to upload either image or word document into either access or
    > SQL server database
    > so far I am doing some small testings and what I can do is upload the
    > file from first page and display at the next
    > page with (both image or word are working fine).
    > however, I cann't insert them into the database, Plus, what type
    > should I use in access database?
    > anyone who has this type of project, please help me out
    > below is my current test code
    > <%
    > FormSize = Request.TotalBytes
    > FormData = Request.BinaryRead( FormSize )
    > 'bnCRLF = chrB( 13 ) & chrB( 10 )
    > 'Divider = LEFTB( FormData, INSTRB( FormData, bnCRLF ) - 1 )
    > 'DataStart = INSTRB( FormData, bnCRLF & bnCRLF ) + 4
    > 'DataEnd = INSTRB( DataStart + 1, FormData, divider ) - DataStart
    > 'Response.ContentType = "image/gif"
    > 'Response.ContentType = "application/msword"
    > 'Response.BinaryWrite MIDB( FormData, DataStart, DataEnd )
    > 'Response.BinaryWrite FormData
    > %>
    > <!--Create and Open the Databse Connection-->
    > <% Set connCW = Server.CreateObject("ADODB.Connection") %>
    > <% connCW.Open ="Driver={Microsoft Access Driver (*.mdb)}; " &_
    > "DBQ=" & Server.Mappath("track.mdb") %>
    > <%
    > sql = "INSERT INTO upload (FileName) VALUES('" & FormData & "')"
    > Set rs = connCW.Execute(sql)
    > %>
    >
    > I got error saying type mismatch
    >
    > thanks in advance
    > wei
     
    joker, Sep 8, 2004
    #4
  5. weiwei

    Roland Hall Guest

    "John" wrote in message news:...
    : Roland,
    :
    : Do you have a code sample of how you run the doc file
    download/edit/upload?
    : Or is there a link to sample code at MS or elsewhere that you can pass on?
    : Or even a general description of the process -- e.g. ... use
    : Response.BinaryWrite for ...
    :
    : I'm obviously a bit of a beginner at this. I've been looking about the net
    : for awhile, likely in the wrong places, and haven't been able to find a
    good
    : model.

    Hi John...

    I use ASPUpload but you can use a pure ASP solution without a component.
    The third link Joker listed should provide the information you're looking
    for.


    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Sep 8, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave
    Replies:
    2
    Views:
    3,685
    Steve C. Orr [MVP, MCSD]
    Oct 4, 2004
  2. ad
    Replies:
    1
    Views:
    2,632
    =?Utf-8?B?RWx0b24gVw==?=
    May 27, 2005
  3. =?Utf-8?B?U2FyYXY=?=

    Upload a file without file Upload control - ASP.Net

    =?Utf-8?B?U2FyYXY=?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,585
    Bruce Barker
    Aug 3, 2005
  4. p.
    Replies:
    10
    Views:
    659
    Albert van der Horst
    Jan 28, 2008
  5. Pk
    Replies:
    0
    Views:
    157
Loading...

Share This Page