Image Upload After Insert to image to Byte

Jayakumars
Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 1685
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)
objconn.Open()
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")
Sqlcmd.ExecuteNonQuery()

Comments or Responses

Login to post response