title: Fileupload Image not getting inserted..
body: <p>I have an ASP.NET FileUpload control. In the code-behind file, I used class to insert values-</p>
  
  <pre><code>public void Insertcert()
          {
              String KKStech = @"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=KKSTech;Integrated Security=True";
              SqlConnection conn = new SqlConnection(KKStech);
  
              try
              {
                  if (FileUpload1.HasFile)
                  {
                      byte[] productImage = FileUpload1.FileBytes;
                      String insertstring2 = @"insert into Cert(CertName, CertLogo)
                                         values(@CertName, @CertLogo)";
                      SqlCommand cmd = new SqlCommand(insertstring2, conn);
                      cmd.CommandText = insertstring2;
                      cmd.CommandType = CommandType.Text;
                      conn.Open();
                      cmd.Parameters.AddWithValue("@CertName", TextBox18.Text);
                      cmd.Parameters.Add("@CertLogo", SqlDbType.VarBinary).Value = productImage;
                      cmd.ExecuteNonQuery();
  
                  }
  
              }
  
  
              finally
              {
                  conn.Close();
              }
  </code></pre>
  
  <p>Executing it here-</p>
  
  <pre><code>protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
          {
             Insertcert();
          }
  </code></pre>
  
  <p>I am using Wizard control to insert Certifications of the Employee:</p>
  
  <pre><code>&lt;asp:Wizard ID="Wizard1" runat="server"  
       OnFinishButtonClick="Wizard1_FinishButtonClick" 
          Width="266px" ActiveStepIndex="0"&gt;
          &lt;WizardSteps&gt;
              &lt;asp:WizardStep ID="WizardStep1" runat="server" Title="Step 2"&gt;
  &lt;asp:Label ID="Label19" class="caption" runat="server" Text="Certification Name:"&gt;&lt;/asp:Label&gt;
              &lt;asp:TextBox ID="TextBox18" class="box" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;br /&gt;&lt;br /&gt;
  
              &lt;asp:Label ID="Label20" class="caption" runat="server" Text="Certification Logo:"&gt;&lt;/asp:Label&gt;
               &lt;asp:FileUpload ID="FileUpload1" class="box" runat="server" /&gt; &lt;br /&gt;&lt;br /&gt;
  </code></pre>