I have problem inserting picture to the database. After it had insert to the database, will they show picture inside or only show the file name?
Here are the codes for inserting to the db:
Dim cnn As New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Inetpub\wwwroot\button\movie.mdb")
Dim strSQL As String = "INSERT INTO movieDet([pic]) VALUES('" + File1.PostedFile.FileName + " ')"
Dim cmd2 As New OleDbCommand(strSQL, cnn)
Dim dr As OleDbDataReader
If Not File1.PostedFile Is Nothing And _
File1.PostedFile.ContentLength > 0 Then
Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
Try
cnn.Open()
dr = cmd.ExecuteReader()
Response.Write("The file has been uploaded.")
Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
Else
Label14.Text = "Please select a file to upload."
End If
After i had clicked submit, it gave me an error message. Said that the connection is closed. Anybody can help me? Urgent. Thank you!
Rgds,
tiffany
Here are the codes for inserting to the db:
Dim cnn As New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Inetpub\wwwroot\button\movie.mdb")
Dim strSQL As String = "INSERT INTO movieDet([pic]) VALUES('" + File1.PostedFile.FileName + " ')"
Dim cmd2 As New OleDbCommand(strSQL, cnn)
Dim dr As OleDbDataReader
If Not File1.PostedFile Is Nothing And _
File1.PostedFile.ContentLength > 0 Then
Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
Try
cnn.Open()
dr = cmd.ExecuteReader()
Response.Write("The file has been uploaded.")
Catch Exc As Exception
Response.Write("Error: " & Exc.Message)
End Try
Else
Label14.Text = "Please select a file to upload."
End If
After i had clicked submit, it gave me an error message. Said that the connection is closed. Anybody can help me? Urgent. Thank you!
Rgds,
tiffany