Link to home
Start Free TrialLog in
Avatar of HawaiiDragon
HawaiiDragon

asked on

saving a word document to a data base

Hello experts I have a new problem.

 I have a web app that stores various text boxes and checkboxes to a database. I need to be able to allow the users to save word documents as well. This is my problem.

In my database (tbl_info) I have a fleld named (ConsentDocument) it is listed as a Data Type of varbinary(1024) and it is set to allow nulls in case the field is not used/required per user case by case basis.

my stored proc looks like this
__________________________
ALTER PROCEDURE [dbo].[P_sp_DetailedResearchSummary_PP]
      /*
      (
      @parameter1 int = 5,
      @parameter2 datatype OUTPUT
      )
      */
      @summary      varchar(500),
      @purpose      varchar(500),
      @methods      varchar(500),
      @schoolBased varchar(500),
      @listofSurveys      varchar(500),
      @surveyDoc      varbinary(1024),
      @international      varchar(500),
      @user nvarchar(10),
      @pass nvarchar(20)

AS
      /* SET NOCOUNT ON */
      UPDATE tbl_info
      SET      ResearchSummary = @summary,
            ResearchPurpose = @purpose,
            MethodsAndProcedures = @methods,
            SchoolBasedResearch = @schoolBased,
            ListofSurveys = @listofSurveys,
            SurveyDoc = @surveyDoc,
            InternationalResearch = @international
      WHERE ParkIDIRB = @user
      AND ParkIRBPass = @pass
      RETURN
__________________________________

and then my C# code behind looks like this... (yes I know its currently commented out : ) )

  //if (ddlFactStafStuQuestion.SelectedValue == "Yes")
            //{
            //    SqlConnection con = new SqlConnection(@"Data Source=x;Initial Catalog=Wdb_IRB;User Id=Ix;Password=x;");
            //    con.Open();
            //    SqlCommand cmd = new SqlCommand("P_sp_DetailedResearchSummary_PP", con);
            //    cmd.CommandType = CommandType.StoredProcedure;
            //    cmd.Parameters.AddWithValue("@summary", TBResearchSummary.Text);
            //    cmd.Parameters.AddWithValue("@purpose", TBPurpose.Text);
            //    cmd.Parameters.AddWithValue("@methods", TBMethods.Text);
            //    cmd.Parameters.AddWithValue("@schoolBased", TBSchoolBasedResurch.Text);
            //    cmd.Parameters.AddWithValue("@listofSurveys", TBMeasures.Text);
            //    cmd.Parameters.AddWithValue("@surveyDoc", FULDocument1.FileContent);
            //    cmd.Parameters.AddWithValue("@user", TBParkID.Text);
            //    cmd.Parameters.AddWithValue("@pass", TBParkIRBPass.Text);
            //    cmd.ExecuteNonQuery();
            //    con.Close();

            //}
-----------------------------------------------------------------

Can anyone tell me what in the world I am doing wrong or how to complete this task please?
ASKER CERTIFIED SOLUTION
Avatar of geigo
geigo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HawaiiDragon
HawaiiDragon

ASKER

where did you find this information it looks like it accidentally got cut off in the middle?
hmmmm its not working.... any ideas?
What part is not working?
the table was not updated .... yet it built.... here is the modified code.

protected void Button5_Click1(object sender, EventArgs e)
        {
            testlbl.Visible = true;

            SqlConnection con = new SqlConnection(@"Data Source=x;Initial Catalog=Wdb_IRB;User Id=x;Password=x;");
               con.Open();
              SqlCommand cmd = new SqlCommand("InsertFile", con);
                cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@FileName", FileUpload4.PostedFile.FileName);
            cmd.Parameters.Add(new SqlParameter("@Extension", FileUpload4.PostedFile.GetType()); //"Extension of Uploaded File"));
            cmd.Parameters.Add(new SqlParameter("@Content", FileUpload4.PostedFile.ContentType(); //"byte array (byte[]) of uploaded file"));
            con.Close();
I actually just created a dll to handel this thanks for all your hard work