title: stuck while uploading image file in sql server though vb.net
body: <p>Reposting the same question because after posting, could not edit the question. please read the bottom especially, if u read this question before -</p>
  
  <p>ok so this is the code i used from this site. everything works fine, but i need a little different code to upload image, and i dont know what to do - here's the code -</p>
  
  <pre><code>Private Sub btnAttach_Click(ByVal sender As System.Object, _  
  ByVal e As System.EventArgs) Handles btnAttach.Click  
      Dim iLength As Integer = CType(File1.PostedFile.InputStream.Length, Integer)  
      If iLength = 0 Then Exit Sub 'not a valid file  
      Dim sContentType As String = File1.PostedFile.ContentType  
      Dim sFileName As String, i As Integer  
      Dim bytContent As Byte()  
      ReDim bytContent(iLength) 'byte array, set to file size  
  
  'strip the path off the filename  '
  i = InStrRev(File1.PostedFile.FileName.Trim, "\")  
  If i = 0 Then  
      sFileName = File1.PostedFile.FileName.Trim  
  Else  
      sFileName = Right(File1.PostedFile.FileName.Trim, Len(File1.PostedFile.FileName.Trim) - i)  
  End If  
  
  Try  
      File1.PostedFile.InputStream.Read(bytContent, 0, iLength)  
      With cmdInsertAttachment  
          .Parameters("@FileName").Value = sFileName  
          .Parameters("@FileSize").Value = iLength  
          .Parameters("@FileData").Value = bytContent  
          .Parameters("@ContentType").Value = sContentType  
          .ExecuteNonQuery()  
      End With  
  Catch ex As Exception  
      'Handle your database error here  
      dbConn.Close()  
  End Try  
  Response.Redirect(Request.Url.ToString) 'Refresh page 
  End Sub  
  </code></pre>
  
  <p>everything works fine except when it comes to this part -</p>
  
  <pre><code>With cmdInsertAttachment  
      .Parameters("@FileName").Value = sFileName  
      .Parameters("@FileSize").Value = iLength  
      .Parameters("@FileData").Value = bytContent  
      .Parameters("@ContentType").Value = sContentType  
      .ExecuteNonQuery()  
  End With  
  </code></pre>
  
  <p>I am not using with cmdinsertattachment. I am using Html - Input(File) from the HTML toolbox. the ID of the input file is ID="upldimg". </p>
  
  <p>so how do i insert this into my table which is -</p>
  
  <pre><code>Column1 ID identity
  Column2 Img image
  Column 3 Description varchar(200).
  </code></pre>
  
  <p>please tell me the insert statement like -</p>
  
  <pre><code>INSERT into table1 (Img, Description) values (???, txtdescription.text)
  </code></pre>
  
  <p>Do i do upldimg.text in the insert statement?</p>