Image Upload After Insert to image to Byte

Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 1063
I have Post the Code
Image Upload After Insert to image to Byte

Assign Session - Code
If (Fp.HasFile) Then
If (Fp.PostedFile.ContentLength < 102400) Then
Dim CntLen As Integer = Fp.PostedFile.ContentLength
imgbyt = New Byte(CntLen - 1) {}
Dim img1 As HttpPostedFile = Fp.PostedFile
img1.InputStream.Read(imgbyt, 0, CntLen)
Session("imgByte") = imgbyt
End If
End If

Insert Code

Dim sqry As String = "Insert into TblEmp(Id,Name,Empno,Amount) values(@Id,@Name,@Empno,@Amount)"
Dim Sqlcmd As New SqlCommand(sqry, Dbconn)
Sqlcmd.Parameters.Add("@Id", SqlDbType.Int).Value = Convert.ToInt32(Session("ID"))
Sqlcmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = txtNAme.Text
Sqlcmd.Parameters.Add("@Empno", SqlDbType.VarChar).Value = TxtEmpno.Text
Sqlcmd.Parameters.Add("@Amount", SqlDbType.VarChar).Value = TxtAmount.Text
Sqlcmd.Parameters.Add("@Img1", SqlDbType.Image).Value = Session("imgByte")

Comments or Responses

Login to post response