Help Problem upload file into the database.....urgent? , db Antarctica
  • 12 years ago

     Hi friends i m trying to upload file into the database but i got following error..plz help its urgent.

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.OleDb;
    using System.IO;
    using System.ComponentModel;
    using System.Drawing.Imaging;
    using System.Text;

    public partial class _Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            //http://localhost/addressbook/Default.aspx?filepath1="samplevcffile.vcf";//when i excute it into the browser

           String filepath = Request.QueryString["filepath1"];
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("db2.mdb");//server.mappath("db2.mdb") + ";";
            OleDbConnection cn = new OleDbConnection(strConn);

                OleDbCommand cmd = new OleDbCommand("insert into text_table (vcffile) values(@)", cn);

                String str2 = "H:\\"+filepath;//Path.GetFileName(read);

                FileStream fs = new FileStream(str2, FileMode.Open, FileAccess.Read);

                Byte[] txtbyte = new Byte[fs.Length];

                fs.Read(txtbyte, 0, txtbyte.Length);


                OleDbParameter param = new OleDbParameter("@vcf", System.Data.OleDb.OleDbType.VarBinary, txtbyte.Length, ParameterDirection.Input, false,
                 0, 0, null, System.Data.DataRowVersion.Current, txtbyte);




                Response.Write("Vcf File Successfully Uploaded into the Database");
            catch (Exception Ex)

    ERROR://System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path) at System.IO.Path.GetFileName(String path) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) at _Default.Page_Load(Object sender, EventArgs e) in h:\AddressBook\Default.aspx.cs:line 47 

  • 12 years ago


    What is the filepath that you are putting in?  i see you are response writing it, can you let us know what that is?



Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann