Click here to Skip to main content
15,897,371 members
Home / Discussions / Database
   

Database

 
QuestionRe-indexing Pin
vanikanc10-Jan-11 6:57
vanikanc10-Jan-11 6:57 
AnswerRe: Re-indexing Pin
David Mujica10-Jan-11 7:31
David Mujica10-Jan-11 7:31 
QuestionSQL Server row lock Pin
Tridip Bhattacharjee9-Jan-11 23:59
professionalTridip Bhattacharjee9-Jan-11 23:59 
AnswerRe: SQL Server row lock Pin
Pete O'Hanlon10-Jan-11 1:01
mvePete O'Hanlon10-Jan-11 1:01 
AnswerImplement your own locking Pin
David Mujica10-Jan-11 3:04
David Mujica10-Jan-11 3:04 
QuestionInsert not working ?? Pin
scorp_scorp9-Jan-11 20:05
scorp_scorp9-Jan-11 20:05 
AnswerRe: Insert not working ?? Pin
Estys9-Jan-11 23:54
Estys9-Jan-11 23:54 
QuestionDatabase Extraction Help Pin
crain19819-Jan-11 6:24
crain19819-Jan-11 6:24 
Am I extracting the blob file correctly?

Private Function decryption()

        'This is function is the same as encryption with just a few changes'
        'loading the xml document'


        Dim key As Byte()
        Dim IV As Byte()


        'The hardcoded password goes here'
        'This is a section just in case you want to a password to your encrypted files'
        key = keyencryption(LoginForm.Password_TextBox.Text)
        IV = IVCreation(LoginForm.Password_TextBox.Text)
        'if there is an error in the application. A error message will be displayed'
        Try

            'checking to make sure the text box isn't null'
            If (Decrypt_TextBox.Text = "") Then
                MessageBox.Show("Need to put in the file location or select file in grid for decryption")
            Else

                'declaring string for file'
                Dim filename As String
                'Getting the file name that is selected'
               
                filename = getFilename()
                'Starting to abstract the data from the database'
                database.ConnectionString = "Data Source = FileVault.db3;"
                database.Open()
                Dim command As SQLite.SQLiteCommand
                Dim sqlstatement As String
                command = database.CreateCommand
                'The following will get the bytes of the file'
                Dim filesize As Integer
                sqlstatement = "SELECT FileSize From Vault WHERE FileName=@file;"
                command.CommandText = sqlstatement
                command.Parameters.AddWithValue("@file", filename)
                Dim reader As SQLite.SQLiteDataReader
                reader = command.ExecuteReader
                filesize = reader.GetValue(0)
                reader.Close()
                MessageBox.Show(filesize)
                Dim data(filesize) As Byte
                'The following should get the data'
                sqlstatement = "SELECT FileData FROM Vault WHERE FileName=@file;"
                command.CommandText = sqlstatement
                command.Parameters.AddWithValue("@file", filename)

                Dim buf() As Byte


                'This gets the file from the database'
                reader = command.ExecuteReader


                'The following should get the file back to its original form'
                buf = reader.GetValue(0)




                'This is go into the Safe and retrieve file'
                Dim datawrite As New System.IO.FileStream("Safe", IO.FileMode.Open, IO.FileAccess.ReadWrite)
                datawrite.SetLength(0)
                datawrite.Write(buf, 0, buf.Length)
                datawrite.Close()
                reader.Close()
                Dim fileinput As New System.IO.FileStream("Safe", IO.FileMode.Open, IO.FileAccess.ReadWrite)

                'specific file output location wiht proper extension'
                Dim fileoutput As New System.IO.FileStream(Decrypt_TextBox.Text & "\" & filename, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
                'The next line makes sure that the file is empty'

                'Declaring variables for encryption'

                Dim buffer(4096) As Byte 'Holds the bytes for processing

                Dim BytesProcessed As Double 'running count for bytes that are processed'

                Dim filelength As Double = fileinput.Length() 'Length of file coming in where intEnd will be greater than intStart'

                Dim bytesinblock As Integer 'current bytes in block'

                Dim crypto As CryptoStream

                'Declaring crypto service provider'
                Dim scRijndael As New System.Security.Cryptography.RijndaelManaged

                'setting up progress bars
                Encrypt_ProgressBar.Value = 0
                Encrypt_ProgressBar.Maximum = 100

                crypto = New CryptoStream(fileoutput, scRijndael.CreateDecryptor(key, IV), CryptoStreamMode.Write)

                While (fileinput.Read(buffer, 0, 4096) > 0)
                    'reading the file'
                    bytesinblock = buffer.Length
                    'writing the file to cryptoStream'
                    crypto.Write(buffer, 0, bytesinblock)
                    'updating bytes processed'
                    BytesProcessed = BytesProcessed + CLng(bytesinblock)
                    'equation for updating bytes in block'
                    Decrypt_ProgressBar.Value = CInt((BytesProcessed / filelength) * 100)
                End While

                crypto.Close()
                fileinput.SetLength(0)
                fileoutput.Close()
                fileinput.Close()

                MessageBox.Show("File is done decrypting")
                Decrypt_ProgressBar.Step = 0
                Decrypt_ProgressBar.Value = 0
                Decrypt_TextBox.Text = ""
            End If

        Catch ex As Exception
            MsgBox(ex.Message.ToString)
            

        End Try

        Return 1


I have no clue what I'm doing wrong here. It keeps saying that the file length is invalid for all lengths. I think its a problem with extracting from the database. The database type is Blob in SQLite. This is the only thing I need to complete to have this program done. Can anyone help?
AnswerRe: Database Extraction Help Pin
crain19819-Jan-11 10:29
crain19819-Jan-11 10:29 
QuestionRe: Database Extraction Help Pin
Luc Pattyn9-Jan-11 12:18
sitebuilderLuc Pattyn9-Jan-11 12:18 
AnswerRe: Database Extraction Help Pin
crain19819-Jan-11 13:12
crain19819-Jan-11 13:12 
GeneralRe: Database Extraction Help Pin
crain19819-Jan-11 13:13
crain19819-Jan-11 13:13 
GeneralRe: Database Extraction Help Pin
Luc Pattyn9-Jan-11 13:47
sitebuilderLuc Pattyn9-Jan-11 13:47 
GeneralRe: Database Extraction Help Pin
crain19819-Jan-11 15:51
crain19819-Jan-11 15:51 
QuestionStoring images in oracle 9i Pin
noora-m8-Jan-11 18:22
noora-m8-Jan-11 18:22 
AnswerRe: Storing images in oracle 9i Pin
Mycroft Holmes9-Jan-11 11:59
professionalMycroft Holmes9-Jan-11 11:59 
QuestionDatabase server extremely slow and poor performance Pin
vanikanc7-Jan-11 5:05
vanikanc7-Jan-11 5:05 
AnswerRe: Database server extremely slow and poor performance Pin
J4amieC7-Jan-11 5:52
J4amieC7-Jan-11 5:52 
AnswerRe: Database server extremely slow and poor performance Pin
thatraja7-Jan-11 6:47
professionalthatraja7-Jan-11 6:47 
QuestionSQL Jobs stop Pin
vanikanc5-Jan-11 7:56
vanikanc5-Jan-11 7:56 
AnswerRe: SQL Jobs stop Pin
Corporal Agarn5-Jan-11 8:08
professionalCorporal Agarn5-Jan-11 8:08 
AnswerRe: SQL Jobs stop Pin
Simon_Whale5-Jan-11 22:13
Simon_Whale5-Jan-11 22:13 
QuestionAccess to stored procs on different database servers Pin
vanikanc5-Jan-11 5:00
vanikanc5-Jan-11 5:00 
AnswerRe: Access to stored procs on different database servers Pin
DoctorMick5-Jan-11 6:14
DoctorMick5-Jan-11 6:14 
GeneralRe: Access to stored procs on different database servers Pin
vanikanc5-Jan-11 6:48
vanikanc5-Jan-11 6:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.