Here is my code:
Dim imgStream As Stream = fUpLoadImage.PostedFile.InputStream()
Dim imgName As String
Dim imgContentType As String
Dim imgLen As Int32
Dim imgbin() As Byte
Dim imgName2 As String
Dim imgContentType2 As String
Dim imgbin2() As Byte
imgLen = fUpLoadImage.PostedFile.ContentLength
imgContentType = fUpLoadImage.PostedFile.ContentType
Dim UserId As String
Dim PatientId As String
Dim RecordId As String
UserId = txtInsertUserId.Text.ToString
PatientId = txtInsertPatientId.Text.ToString
RecordId = txtInsertRecordId.Text.ToString
Dim imgBinaryData(imgLen) As Byte
Dim n As Int32 = imgStream.Read(imgBinaryData, 0, imgLen)
imgbin = imgBinaryData
'Save images to Database
Dim MyConnection As New OleDbConnection(ConfigurationSettings.AppSettings( "ConnectionString"))
MyConnection.Open()
Dim oCMD As New OleDbCommand("INSERT INTO RESOURCE (userid,patientid,recordid,resourcefileimage) VALUES (?,?,?,?)", MyConnection)
Here is my error message;
Server Error in '/ImageRetreival' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 74:
Line 75: Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
Line 76: Dim imgStream As Stream = fUpLoadImage.PostedFile.InputStream()
Line 77: Dim imgName As String
Line 78: Dim imgContentType As String
Source File: c:\inetpub\wwwroot\ImageRetreival\default.aspx.
vb Line: 76
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ImageRetreival._default.btnInsert_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\ImageRetreival\default.aspx.
vb: 76
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
Sanjeet