i had tried to upload the file to access database. i successfully done that one. now i went into the access database, open the particular table and i had tried to open the file which was uploaded through asp.net. but it shows error. the error is "
A probem occured while microsoft access communicating with ole server or Activex control. i dont know wat is the problem. whether the problem is in coding or access database. i had mention my coding here. can anyone help me
Private Sub up_Click(ByVal sender
As System.Object,
ByVal e As System.EventArgs)
Handles up.Click
Dim intImageSize
As Int64
Dim strImageType
As String
Dim ImageStream
As Stream
' Gets the Size of the Image
intImageSize = file1.PostedFile.ContentLength
' Gets the Image Type
strImageType = file1.PostedFile.ContentType
' Reads the Image
ImageStream = file1.PostedFile.InputStream
Dim ImageContent(intImageSize)
As Byte
Dim intStatus
As Integer
' Create Instance of Connection and Command Object
'Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
'Dim myCommand As New SqlCommand("sp_person_isp", myConnection)
'Dim oledbconnection1 As OleDbConnection
'Dim oledbcommand1 As OleDbCommand = New OleDbCommand()
'oledbconnection1 = New OleDbConnection("provider = microsoft.jet.oledb.4.0;datasource=c:\inetpub\wwwroot\useless\reports.mdb")
'cnn.Open()
oledbconnection1.Open()
OleDbCommand1.CommandText = "insert into mytbl([imgid]) values (@personimage)"
' Mark the Command as a SPROC
'myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC
Dim prmPersonImage
As New OleDbParameter("@PersonImage", OleDbType.LongVarBinary)
vivekgrs
Member
585 Points
117 Posts
upload the file in access database
Feb 16, 2006 11:01 AM|LINK
hi ,
i had tried to upload the file to access database. i successfully done that one. now i went into the access database, open the particular table and i had tried to open the file which was uploaded through asp.net. but it shows error. the error is " A probem occured while microsoft access communicating with ole server or Activex control. i dont know wat is the problem. whether the problem is in coding or access database. i had mention my coding here. can anyone help me
Private Sub up_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles up.Click
Dim intImageSize As Int64
Dim strImageType As String
Dim ImageStream As Stream ' Gets the Size of the ImageintImageSize = file1.PostedFile.ContentLength
' Gets the Image TypestrImageType = file1.PostedFile.ContentType
' Reads the ImageImageStream = file1.PostedFile.InputStream
Dim ImageContent(intImageSize) As Byte Dim intStatus As IntegerintStatus = ImageStream.Read(ImageContent, 0, intImageSize)
' Create Instance of Connection and Command Object 'Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) 'Dim myCommand As New SqlCommand("sp_person_isp", myConnection) 'Dim oledbconnection1 As OleDbConnection 'Dim oledbcommand1 As OleDbCommand = New OleDbCommand() 'oledbconnection1 = New OleDbConnection("provider = microsoft.jet.oledb.4.0;datasource=c:\inetpub\wwwroot\useless\reports.mdb") 'cnn.Open()oledbconnection1.Open()
OleDbCommand1.CommandText = "insert into mytbl([imgid]) values (@personimage)"
' Mark the Command as a SPROC 'myCommand.CommandType = CommandType.StoredProcedure ' Add Parameters to SPROC Dim prmPersonImage As New OleDbParameter("@PersonImage", OleDbType.LongVarBinary)prmPersonImage.Value = ImageContent
oledbcommand1.Parameters.Add(prmPersonImage)
Try 'ole.Connection = cnnoledbcommand1.ExecuteNonQuery()
oledbconnection1.Close()
Response.Write("New person successfully added!")
Catch SQLexc As OleDbExceptionResponse.Write("Insert Failed. Error Details are: " & SQLexc.ToString())
End Try End Subthanks
m.arunachalam