Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i am trying to make an application that can show report using report viewer and the application can also show pdf file saved in the database. Both of it are running well in my computer. But when i install the application using x64 platform (mine is x86), all those action cant be run. it turns error like this:

" Could not find file 'C:\Users\tiwi\AppData\Local\Apps\2.0\Data\XOPMCLLEJ3Q\KV5LQHME.4A7]ulpj.tion_f2b1c5fe86104d_0001.000_17c245daa62a8b0\Data\Database2.accdb'

All the datagridview that use the same database are running well, only the report viewer dan pdf viewer that show that error. please help

here is my code to save pdf file in database

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As       System.EventArgs) Handles Button8.Click
    Call PathFile()
    Dim sConnString As String
    oleAccCon = New OleDbConnection(StrAccConn)

    Using oleAccCon

        'Create Command Object, To Make Use Of SQL Query
        'Dim oleAccCommand As New OleDbCommand(strAccQuery, oleAccCon)

        If Microsoft.VisualBasic.Right(Application.StartupPath, 1) = "\" Then
            sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database2.accdb;Persist Security Info=False;"
        Else
            sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database2.accdb;Persist Security Info=False;"
        End If
        Conn = New OleDbConnection(sConnString)
        Conn.Open()
        cmd.Connection = Conn
        'If (TbHps.Text <> "") And (TbGambar.Text <> "") And (TbBoq.Text <> "") And (TbKontrak.Text <> "") And (TbSpek.Text <> "") Then
        strAccQuery = "INSERT INTO tbFileBarang (nama_skpd, nama_paket, path_hps, path_boq, path_gambarkerja, path_kak, path_spekteknis, path_rancangankontrak) VALUES (@namaskpd, @namapaket, @pathhps,@pathboq,@pathgambar, @pathkak, @pathspek, @pathkontrak)"

        ' Else
        '    cmd.CommandText = "UPDATE tbFileKonstruksi set image_description = @img_desc, [image] = @img where id=@id"
        'End If
        oleAccCon = New OleDbConnection(StrAccConn)

        Dim oleAccCommand As New OleDbCommand(strAccQuery, oleAccCon)

        MessageBox.Show(pathFullHps)
        MessageBox.Show(pathFullBoq)
        MessageBox.Show(pathFullGambar)
        MessageBox.Show(pathFullKak)
        MessageBox.Show(pathFullKontrak)
        MessageBox.Show(pathFullSpek)

        oleAccCommand.Parameters.AddWithValue("namaskpd", CbSkpd.Text)
        oleAccCommand.Parameters.AddWithValue("namapaket", CbPaket.Text)
        oleAccCommand.Parameters.AddWithValue("pathhps", pathFullHps)
        oleAccCommand.Parameters.AddWithValue("pathboq", pathFullBoq)
        oleAccCommand.Parameters.AddWithValue("pathgambar", pathFullGambar)
        oleAccCommand.Parameters.AddWithValue("pathkak", pathFullKak)
        oleAccCommand.Parameters.AddWithValue("pathspek", pathFullSpek)
        oleAccCommand.Parameters.AddWithValue("pathkontrak", pathFullKontrak)

        oleAccCon.Open()

        oleAccCommand.ExecuteNonQuery()

    End Using

    'cmd.ExecuteNonQuery()
    MsgBox("Image has been save.")


End Sub


what is wrong with this code ?
Posted
Updated 1-Feb-15 21:47pm
v2
Comments
CHill60 2-Feb-15 3:55am    
Did you actually copy the database over when you installed?
Does the userid have permissions to access that file?
Nilendra Nath 2-Feb-15 5:41am    
here is a code:

If Microsoft.VisualBasic.Right(Application.StartupPath, 1) = "\" Then
sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database2.accdb;Persist Security Info=False;"
Else
sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database2.accdb;Persist Security Info=False;"


what is the difference between if and else part?
if application is not able to connect to db, so either you have not copied db file in correct path or application is getting right path of db.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900