9 Replies - 1393 Views - Last Post: 19 July 2013 - 10:07 AM Rate Topic: -----

#1 Nigels  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 66
  • Joined: 17-May 13

Does anyone here use Visual studio 2012? Compile error

Posted 24 June 2013 - 03:08 AM

Hi, I have been working with Visual studio 2012. I have a created a small bit of software which works perfect when I run it in debug mode.

I wanted to publish my software so I can use it on another computer, so I clicked on "Build" then "Publish" I received no errors while doing this.

I then created a rar archive of my software and placed it on a usb memory stick. I then transferred the software to my other PC. I install the software using the .exe file and it installs once again with no errors.

When I run my software from the start menu it tells me this error

"Could not find file 'C:\Users\Nige\AppData\Local\Apps\2.0\2GKHLO4K.J93\4M6EYCZL.BJG\chil..tion_3ea6cf6508f30245_0001.0000_cb2298d088426d09\Database1.mdb'.

Have I missed out a step I should of done to make this work?

Thanks Nige.

Is This A Good Question/Topic? 0
  • +

Replies To: Does anyone here use Visual studio 2012? Compile error

#2 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 976
  • Joined: 09-May 09

Re: Does anyone here use Visual studio 2012? Compile error

Posted 24 June 2013 - 04:51 AM

last bit of the error -> Database1.mdb


did u move the database aswell, if your project is referencing a database then you need not to make this value static and use something like

dbLocation as string = Path.GetDirectoryName(Application.ExecutablePath) +"\DatabaseLocation"


check the location on the machine that works and see whats there, this will answer this topic for you :)/>

Hope this helps

This post has been edited by deery5000: 24 June 2013 - 04:52 AM

Was This Post Helpful? 1
  • +
  • -

#3 Nigels  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 66
  • Joined: 17-May 13

Re: Does anyone here use Visual studio 2012? Compile error

Posted 24 June 2013 - 11:47 PM

thanks for the answer, when I had this working on the other computer computer my string was

"C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"
Whic was perfect in debug mode

When I published it for some reason it did not add my database which is supposed to be built in to the app so it will run local. So I simply copied it and placed it in the root of the directory I had just published. Anyway it complasined it could not find
C:\Users\Nige\

which is fair enough because I am now on a different computer which don't even have a user called Nige

So what I did was change the path from
"C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"

and simply leave it at
\bin\Debug\Database1.mdb

But now it tells me it cant find
\bin\Debug\Database1.mdb

After looking a bit more that's no surprise it cant find \bin\Debug\Database1.mdb
Because when I published the document it does not publish the folder \bin\Debug\
So I then changed the path to simply point at the database
Database1.mdb
Now I get cant find C:/Database1.mdb

What I don't understand is for all the help and advice people have been giving me while I have been learning databases. Has no one said sooner that the path they have been telling me to write and learn would be no good if I wanted to publish my application.

Am I right in saying that in future with all the learning and practice I am putting in I will need to change the path manually from
"C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"
to something else every time I want to publish something that I want to include a local database in

If someone had a big piece of software they had created in Visual studio 2012 with let's say a hundred pages of code. That would create them a lot of work changing the path on all those document.s just to publish it.
Especially if they had to go back and keep making alterations. I would of thought that Visual studio as good as it is would of had a setting some where that you could change. Just so you could tell it well actually your going to be including a local database in this application.

My first thoughts of visual studio were this is amazing, I just cant get my head round the fact something as simple as publishing the software you have spent ages creating and VS wont even include the database you have to do it manually.
Anyway I will look at the above suggestion and see where that leads me.
Thanks Nige.
Was This Post Helpful? 0
  • +
  • -

#4 Nigels  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 66
  • Joined: 17-May 13

Re: Does anyone here use Visual studio 2012? Compile error

Posted 25 June 2013 - 02:56 AM

And yes I moved the database as well,
My original connection string was,

Dim Builder As New OleDb.OleDbConnectionStringBuilder With
            {
                .Provider = "Microsoft.ACE.OLEDB.12.0",
                .DataSource = IO.Path.Combine(Application.StartupPath, "C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"),
                .PersistSecurityInfo = True
            }


I just do not yet understand what I should change it be like. Forgive my ignorance, it would seem the more I learn the more I need to learn. But I will get there.
Thanks Nige.
Was This Post Helpful? 0
  • +
  • -

#5 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 976
  • Joined: 09-May 09

Re: Does anyone here use Visual studio 2012? Compile error

Posted 25 June 2013 - 08:42 AM

I can understand that your are frustrated with the publish feature but do not let it put you off.

I never publish applications so ive no real experience with it. When im finished with my application I build an installer, this allows me to include whatever files I need.

when specifying locations for images, folders and anything really I always use Application.StartupPath, this gives the base of the application regardless of where it is installed

dim myDocumentFolder = Application.StartupPath + "\myDocumentFolder"




Here is your issue
.DataSource = IO.Path.Combine(Application.StartupPath, "C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"), 



add a breakpoint to your code and when the compiler hits it hover over Application.StartupPath, check out the location

now step back and think, where is this location Application.StartupPath, "C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"

click start and chuck it into the search bar , can it be found?

hope this helps

This post has been edited by deery5000: 25 June 2013 - 08:45 AM

Was This Post Helpful? 0
  • +
  • -

#6 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 976
  • Joined: 09-May 09

Re: Does anyone here use Visual studio 2012? Compile error

Posted 25 June 2013 - 08:47 AM

View Postdeery5000, on 25 June 2013 - 08:42 AM, said:

I can understand that your are frustrated with the publish feature but do not let it put you off.

I never publish applications so ive no real experience with it. When im finished with my application I build an installer, this allows me to include whatever files I need.

when specifying locations for images, folders and anything really I always use Application.StartupPath, this gives the base of the application regardless of where it is installed

dim myDocumentFolder = Application.StartupPath + "\myDocumentFolder"




Here is your issue
.DataSource = IO.Path.Combine(Application.StartupPath, "C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"), 



add a breakpoint to your code and when the compiler hits it hover over Application.StartupPath, check out the location

now step back and think, where is this location?
Application.StartupPath, "C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"

remember you are combining 2 paths . . . . to make one

hope this helps

Was This Post Helpful? 0
  • +
  • -

#7 lcp2000  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 25-June 13

Re: Does anyone here use Visual studio 2012? Compile error

Posted 25 June 2013 - 07:48 PM

View PostNigels, on 25 June 2013 - 02:56 AM, said:

And yes I moved the database as well,
My original connection string was,

Dim Builder As New OleDb.OleDbConnectionStringBuilder With
            {
                .Provider = "Microsoft.ACE.OLEDB.12.0",
                .DataSource = IO.Path.Combine(Application.StartupPath, "C:\Users\Nige\Documents\Visual Studio 2012\Projects\MS_Access_SimplePassword\bin\Debug\Database1.mdb"),
                .PersistSecurityInfo = True
            }


I just do not yet understand what I should change it be like. Forgive my ignorance, it would seem the more I learn the more I need to learn. But I will get there.
Thanks Nige.


It seems to me your application is getting confused because it
is looking for your database in a location where it does not exist
on another computer. Right?

In my opinion, wat u need to do is place your database in a location
That exists in every computer (ie: MyDocuments folder) and create a
Connection string with that location. You place the database there by
way of the setup app.

Here's an example of what i do:

Dim mydb = my.computer. Filesystem.specialdirectories.mydocuments & "\mydbhere.mdb"
Dim connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & mydb &"; Persist Security Info=False;"

Hope this helps.
Was This Post Helpful? 1
  • +
  • -

#8 Nigels  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 66
  • Joined: 17-May 13

Re: Does anyone here use Visual studio 2012? Compile error

Posted 09 July 2013 - 04:34 AM

Thanks for both of you who responded, sorry for my late reply.

deery5000,
I never publish applications so ive no real experience with it. When im finished with my application I build an installer, this allows me to include whatever files I need.

You say you do not publish an app you build an installer is the result the same? ie if I was to build an installer can I then make something available to download with it. If so can you tell me how to do this or point my nose in the direction of a good enough tutorial.
Because if I could try something else to make this work I will.


OK this is where I am at now, this is all the code on my page.
Imports System.Data.OleDb

Public Class LoginForm
    Private LoginAttempts As Integer
    Private Sub Initialize()
        Shell("IpConFig /Release")
    End Sub
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    End Sub
    Protected Overrides Sub OnPaintBackground(ByVal prevent As System.Windows.Forms.PaintEventArgs)
        Dim gfx As Graphics = prevent.Graphics
        gfx.DrawImage(My.Resources.Login1, New Rectangle(0, 0, Me.Width, Me.Height))
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtPassword.PasswordChar = System.Convert.ToChar(System.Convert.ToUInt32("6c", 16))
        Shell("IpConFig /Release")
    End Sub



    Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
        Dim myDocumentFolder = Application.StartupPath + "\myDocumentFolder"
        Dim mydb = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Database1.mdb"
        Dim connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & mydb & "; Persist Security Info=False;"


        Dim Builder As New OleDb.OleDbConnectionStringBuilder With
            {
                .Provider = "Microsoft.Jet.OLEDB.4.0",
                .DataSource = IO.Path.Combine(Application.StartupPath, "Database1.mdb"),
                .PersistSecurityInfo = True
            }

        Builder.Add("Jet OLEDB:Database Password", "password")

        Using cn As New OleDbConnection With {.ConnectionString = Builder.ConnectionString}
            Dim Statement As String =
                <SQL>
                    SELECT 
                        UserName, 
                        UserPassword
                    FROM tblContacts
                    WHERE (((UserName)=@UserName) AND ((UserPassword)=@UserPassword));                    
                </SQL>.Value

            Using cmd As New OleDbCommand(Statement, cn)
                cmd.Parameters.AddRange(
                    New OleDbParameter() _
                    {
                        New OleDbParameter With {.ParameterName = "@UserName", .DbType = DbType.String},
                        New OleDbParameter With {.ParameterName = "@Userpassword", .DbType = DbType.String}
                    }
                )

                cmd.Parameters(0).Value = txtUserName.Text
                cmd.Parameters(1).Value = txtPassword.Text
                cn.Open()

                Dim reader As OleDbDataReader = cmd.ExecuteReader
                If Not reader.HasRows Then
                    LoginAttempts += 1
                    If LoginAttempts >= 3 Then
                        MessageBox.Show("Too many attempts")
                        '
                        ' You might want to log this to a log file
                        ' Things like computer name, user name, date/time etc.
                        '
                        Application.ExitThread()
                    End If
                    MessageBox.Show("Login failed")
                    Shell("IpConFig /Release")
                Else
                    Me.Hide()
                    Dim f As New frmMainform
                    f.ShowDialog()

                    Shell("IpConFig /Release")
                    Application.ExitThread()
                End If
            End Using
        End Using
        txtUserName.Text = txtUserName.Text

        If txtUserName.Text <> "" Then
            'do what you want to do

            frmMainform.lblName.Text = Me.txtUserName.Text()

        Else
            'MsgBox("Please Enter Correct Info")
        End If

    End Sub




    Private Sub cmdCancelLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancelLogin.Click
        Close()
    End Sub
   
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        adminLogIn.ShowDialog()
        Me.Hide()


    End Sub
End Class


I am still getting the same error as before. I know I'm a pain in the neck but I have been trying to figure this problem out for nearly 2 weeks now on and off.

Thanks Nige
Was This Post Helpful? 0
  • +
  • -

#9 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 976
  • Joined: 09-May 09

Re: Does anyone here use Visual studio 2012? Compile error

Posted 09 July 2013 - 07:11 AM

There are many applications available out there which allows to easily build and installer for an application. You can add the database to the installer package (best if its empty), oh and I use "Install Creator Pro"

Your initial issue was this error
'C:\Users\Nige\AppData\Local\Apps\2.0\2GKHLO4K.J93\4M6EYCZL.BJG\chil..tion_3ea6cf6508f30245_0001.0000_cb2298d088426d09\Database1.mdb'

it could not find this when you moved to another computer so using the "Application.StartupPath" gets the location of where the application is installed.

eg C:\Users\Nige\Program Files\My password App\

so where is the database ???
C:\Users\Nige\Program Files\My password App\Database\Database1.mdb ??

Think about where the database is located and when you move to another machine , how will you point it to the correct location

My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Database1.mdb" <--------- Is this where the database is , when ur app is installed what path are you pointing too?

Look closely at these lines
Dim mydb = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Database1.mdb"
.DataSource = IO.Path.Combine(Application.StartupPath, "Database1.mdb"),

This post has been edited by deery5000: 09 July 2013 - 07:27 AM

Was This Post Helpful? 1
  • +
  • -

#10 Nigels  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 66
  • Joined: 17-May 13

Re: Does anyone here use Visual studio 2012? Compile error

Posted 19 July 2013 - 10:07 AM

Thanks for your perseverance I am now up and running. And because I now have my own little app that works with a local database I will always have it to reference to when I am creating another.
Thanks Nige.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1