Skip to main content

how to upload a file in sqlserver 2000 databse

 protected void Button4_Click(object sender, EventArgs e)
        {
            string picType = this.FileUpload1.PostedFile.ContentType;
            if (picType != "")
            {
                string picName = this.FileUpload1.FileName;
                SqlConnection conn = new SqlConnection("server=.;database=Test;uid=sa;pwd=issac");
                conn.Open();
                SqlCommand comm = new SqlCommand("insert into test(image) values(@image)", conn);
                comm.Parameters.Add("@image", SqlDbType.Image);     
                comm.Parameters[0].Value = this.FileUpload1.FileBytes;
                comm.ExecuteNonQuery();
                conn.Close();
       
            }
            else
            {

            }

        }

Comments

Popular posts from this blog