I am Inserting Data into Database but i want to check If Duplicate File_name already available in the Database display popup message.
Private Sub FileUploadIntoDatabase()
Try
If objdatabase.getConnection() Then
Dim fileName As String = Path.GetFileName(FileUploadControl.PostedFile.FileName)
Dim filePath As String = "D:\Data_branch_wise\TRANS DATA\SMS\PEN\" + fileName
Dim contentType As String = FileUploadControl.PostedFile.ContentType
'If File.Exists(fileName) Then
' usermsg = String.Format("File Name {0} already exists please select correct file.", fileName)
'Else
Using fs As Stream = FileUploadControl.PostedFile.InputStream
Using br As BinaryReader = New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(CType(fs.Length, Int32))
Dim query As String = "INSERT INTO TRANSACTIONAL_DATA_FILE(STATUS, FILE_NAME, DATA) VALUES(:Status, :FileName, :Data)"
Using command As OracleCommand = New OracleCommand(query, objdatabase.conn)
command.Parameters.AddWithValue("Data", OracleType.Clob).Value = bytes
command.Parameters.AddWithValue("Status", "PEN")
command.Parameters.AddWithValue("FileName", fileName)
Dim count As Integer = command.ExecuteNonQuery()
If count > 0 Then
Response.Write("data inserted")
End If
End Using
End Using
End Using
End If
'End If
Catch ex As Exception
Throw
End Try
Response.Redirect(Request.Url.AbsoluteUri)
End Sub