Open prepopulated SQLite database in Cordova - visual-studio

I am developing a cross platform (Android, IOS, WP) application that needs to have a relatively large prepopulated database. I am using Visual Studio 2013 with Cordova plugins.
Most answers on the internet point here or here. However these links always start with "copy your prepopulated database to the assets folder".
In my Visual Studio project, there is no assets folder. This is what I have:
How should I go about this? Preferably the solution should work on all platforms. Thanks.

No need to copy or to insert the values at first run of your app.
Instead use openDatabase with createFromLocation param as described here:
http://redwanhilali.com/ionic-sqlite/

The SQLite forces you to create THE COMPLETE Database executing "Create Tables" commands in a function inside the App, right?
That function ONLY executes if the Database DON'T EXIST. If already exists = don't execute that function!
So... to the "CREATE TABLE" commands, add "INSERT INTO" commands with what you need to populate! This will only execute the first time.
If you want a cleaner code, you can put all the data in an Array and then execute the Inserts with a For Loop.
(I did this in many Apps and worked like a charm!)
ADDED:
To solve "Code Brevity" I suggest 2 Options:
Option 1 - XML File: Add an external XML file with the info, and just read it in the "create db" function, and execute the "inserts" in a For Loop reading the XML file.
Option 2 - create a special js file (name it "populateDB.js" for example!) and enter all the code there... you won't see the code again!
I hope it helps because you cannot include a DB in your project, you HAVE to create it on the device...

I like your question. It made me think about an upcoming project and how I am going to solve a similar issue.
The link you shared: http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html is a good place to start. The "assets" directory referenced isn't visible because, through Visual Studio you are looking at the Windows platform version of the code. Note, in the Xcode/iOS screen capture in the link you reference, the database file isn't in an assets folder, but rather "Resources" that roughly equates to assets within the Android project.
You will need a Mac and Xcode to build your project for iOS, this can not be done with Visual Studio or on a Windows machine. When the project is created by cordova with the "cordova platform create ios" command, you will see a resources directory and you can continue with your instructions.
Similarly, with Android you can open the Android project in Eclipse, or another editor/file browser and do the same. Myself, I am not brave enough (lack of experience) with Visual Studio to browse other platforms in a Visual Studio Solution.
ADDED NOTE: At http://gauravstomar.blogspot.com/2011/08/prepopulate-sqlite-in-phonegap.html be sure to read through the recent discussions/comments with regard to copying the file into place within the app. Appears to still work fine, but the process has changed slightly with newer versions of Cordova.

When using Visual Studio (and Phonegap), you cannot see assets folder. If you would like to develop prepopulated DB in Visual Studio, you had better apply sqlite plugin.
You need two plugins.
1) Cordova-sqlite-evcore-extbuild-free
2) cordova-plugin-dbcopy ->this plugin will copy your database to assets folder.
I think the following Git will help you.
https://github.com/ymochi/prepopulated-DB-for-hybrid-applications

Related

Unable To Load Moved Visual Studio Project

I am in a real bind here. A programmer long before me made several applications in VS2010. We needed to move all these old applications to a file server so they can be backed up etc while awaiting updates. I am attempting to open this solution "Intranet". However, when I attempt this I receive the following error message:
\fs01\it$\Application-Source-Code\Projects-Important\Projects-Important\FFL Programs\Intranet\ :
error : Error opening web \fs01\it$\Application-Source-Code\Projects-Important\Projects-Important\FFL Programs\Intranet.
Unable to open the Web site '\fs01\it$\Application-Source-Code\Projects-Important\Projects-Important\FFL Programs\Intranet'.
The Web site '\fs01\it$\Application-Source-Code\Projects-Important\Projects-Important\FFL Programs\Intranet' does not exist.
We have a big customer coming in tomorrow morning and I need to take a look at the code to fix an error "a master page error". However, I cannot open this using VS2017 Version Selector. I have attached a screen shot of the sln file into to help assist with a resolution.
Option 1:
Copy your code from your file server (VS2010) see if it is opening/working on your local dev machine (in VS2010 orvs2017)
IF NOT
Option 2:
Still you'll need the above project files, now...
Create a blank solution in VS 2017 (relative to your programming language i.e. C# or Vb.Net etc) - also look for target framework
Locate the project file(s) (for e.g. ".csproj" files for c# projects) one by one manually.
Try to build the individual project( should there be any missing assembly references) and followed by complete solution build.
#NBaua, My brain has been overwhelmed lately. I was attempting to open a project when I needed to open a website. I just went to File --> Open --> Website and all works. Thanks again.

Is it possible to deploy aspnet vnext to azure from a mac?

The kpm pack command needs the runtime for the server - is it possible to install windows runtimes on osx just for the pack and deploy?
Ok, it seems that in order to recognise that the deployment is an aspnet vNext project and to handle that as a 'ProjectK Web Application deployment', you have to make it look like it all came from Visual Studio (or at least that was the only way I managed to get it to work right now)...
I did this by taking an example one from somewhere else...
I took a simple single vnext web project .sln file and changed the project name and project GUID.
I took the .kproj Visual Studio project file and did the same.
There isn't much that needs to be changed - only the name of the project and GUID. It's nice that there isn't any file lists in there so I feel that this might end up as a once-only activity...
I did find that there are some project structure rules that seemed to make it break. You seem to have to have the sln file in the top level folder and a folder underneath for the web project. If there is ONLY a web project then this might seem overkill, but I tried collapsing everything up to the top with the sln file correctly pointing, but that didn't work.
The other thing that you need to make sure you have is a reference to "Microsoft.AspNet.Server.IIS" in the project.json dependencies. Without this, the AspNet.Loader.dll and bin folder don't get deployed.
Apart from that, I am now able to use Sublime Text (or whatever I want on osx), test using "k kestrel", checkin through git and it gets deployed automatically to an azure web site! yippee!
Actually this makes much more sense because it is letting the target decide upon the binaries it needs to satisfy the deployments. Next challenge might be to get it to pull 'my' libraries from a custom NuGet source to get my binary libraries in there and avoid uploading ALL of the source to the website!
Oh - and another tip: Quit kestrel with 'Enter' for a clean quit instead of Z which leaves the port listening but non-functional!

Visual Studio keeps running the old build

I have a simple Silverlight program that displays a bunch of images. I modified it do display more images, but it when I hit "run without debugging" is keeps running the old build with fewer images. When I copy the code into a new project and run it, it works fine for the first time, but then each subsequent change is not displayed. What could be the problem? I'm using Visual Web Developer 2008 Express.
Always check "Configuration Manager" option on "Build" menu in Microsoft Visual Web Developer. The checkBox "build" has to be checked, otherwise it won't build.
Happened to me, I hope this helps others.
I just had this happen to me in VS 2013 for Web. Had to change the Project URL in:
"Project properties"
 "Web" tab
  "Servers"
To a different localhost number and recreate Virtual directory.
Before my Project URL was:
http://localhost:55487/
I changed it to:
http://localhost:55488/
Then clicked "Create Virtual Directory".
Would like to know why this happened in the first place.
I found that I had to close all open instances of Visual Studio before I got it working again
This happens because your cache memory is full. just go to you bin and obj folder and delete all the temporary files. Now it will run properly.
Maybe it's a caching issue (webbrowser / proxy).
To fool the browser try to embed the xap file with an additional parameter that changes every time you open the plugin:
<param name="source" value="ClientBin/BubuApp.xap?<%=Guid.NewGuid().ToString() %>"/>
If this don't help, try to clean the project (delete obj / bin folders & xap file).
I was also suffering from this issue and none of the suggestions worked. I was building a Office.js add-in and debugging was with IIS Express.
What fixed the issue for me was deleting files in
C:\Users\<user>\AppData\Local\Temp\Temporary ASP.NET
Actually, I went ahead and and deleted the entire C:\Users\<user>\AppData\Local\Temp folder out of spite :)
I also had this issue and while some of the fixes above helped temporarily, the one that worked for me was to remove the history and caching in Internet Options.
Go into Internet Option (also available in VS via Tools > options > Environment > Web Browser > Internet Explorer Options).
On the General tab click Settings in the Browsing History section.
On the Temporary Internet Files page select Every time I start
Internet Explorer
On the History tab set the Days to keep history to 0
On the Caches and Database tab make sure Allow website caches and
databases is NOT ticked.
I'm not sure if all of the above are required, but I've made a number of changes to files and so far they have been reflected straight away in the dynamic versions without any noticeable performance problems.
I've also since realised if I set 'Every time I visit the webpage' instead of 'Every time I start Internet Explorer' I don't have to stop and restart the project to see the changes. Which is how it should be!
I used to suffer this. All of this used to be (for me) a folder's contents issue.
Maybe you can check this:
Delete %windir%\microsoft.net\framework\v4.0xxx\Temporary
IIS Express: even if you change the output file for compiled results, you will see in applicationhost.config that many times IISExpress is really "looking" to the default bin folder of your project.
It is even possible that you have different configurations for Debug or Release, so maybe IIS is looking BIN with Release code, and you are now compiling in Debug to another folder, do you understand me?
Happened to me too. Well i dont know the exact reason for this behavior. But when i close the visual C express 10 and then open again and build it builds the new saved file. I guess it still hangs on to the old file when there is an error in some debug mode or something.
Stop all incntance of VS.
Delete all /bin, not just /bin/Debug. All /bin
Remove user option .suo file in solution dir. It will create on self.
Remove all restore windows point
Stop IIS.
6 Start IIS after 1 minutes.
Rebuild solution, Buid projects
It happing on me too. Very nasty. You may restart your computer.
Check for global asembly dll.
Just delete folder 'Release' in project with old code build.
I had the same problem and none of the answers were working for me. It turns out that building the ASP.Net project did not build the Silverlight project, so running without debugging didn't update the Silverlight.
Fix: Right click the Asp.Net project. Build Dependencies > Project Dependencies. Check the Silverlight project. Now building should work.
If this is a web application, change the Project URL with a new port number.
Example :
Change from http://localhost:3688/
To http://localhost:36881/
To do this:
Navigate to Project properties -> Web
Change the URL
Hit "Create Virtual Directory"
Finally, Build and RUN
I had this issue in a web site.
The site referenced 1 of the projects in the solution, and changes to it would not reflect in the debug.
Issue was a third project was referencing an outdated dll of the same same referenced project.
I removed the project and all references in other projects and readded and re-referenced everything and it worked fine.
Check you haven't got two versions of whichever file you're updating (one for one group of users, one for a different group of users).
In my case(VS 2015) it was because of the missing dll in the .exe directory... I made a "clean solution", then additionally deleted all bin and obj folders' contents. Reason to do so was VS keeping to load old dll build. Solution was to select folder of the running debug config, i.e. everytime I rebuild project destination location with dll and a reference to it stays with warning mark for some time until intellitrace does its job. After doing the setup mentioned above, I still have to do a manual rebuild on a project that generates a dll into specified dir. Pressing F5 does nothing, I don't have time to find out why... Main thing is its working for me
I had this recently too and I didn't see the answer here. I was changing an MMI to get rid of redundant buttons, and they didn't go away.
Really old legacy code. To make it keep user settings - like language - someone had made it keep the Settings. I was not allowed to change this, they want it like that.
To get rid of the old settings and allow new ones:
open regedit
navigate to HKEY_CURRENT_USER - Software - MyProject - SubProject
here you see Recent File List and Settings.
Delete Settings completely - don't worry, it will make a new one.
Please check is there any old .tlb file present in someother folder. In my case i was using the .tlb file generated using .NET dll and then created the .tlb file using RegAsm. I tried to use the .tlb file in vb6 code, it still refers old code only. After a long search i found same .tlb file older version found in Visual Studio\VB98 folder. I removed it then it worked fine. This may not be relevent for this issue but could give you another way of thinking
There is a scroll bar at the top which has 3 options:
debug
release
configuration manager
Make sure release is selected.
I had to clear browsing data and it worked in my case

Can't get Visual Studio's "Publish Web Application" to work

I converted a small Web Project to a Web Application in Visual Studio 2010.
When I publish the application via FTP it will delete everything at the destination. And thats it...none of my files get uploaded.
Now, If I select "Replace matching files with local copies" it uploads all my files but it does run my Pre/Post Build commands but never uploads the resulting files (the Build Events create .min.js versions of my JS files).
I figure that whatever I'm doing...I'm doing it wrong.
Help me please.
UPDATE
So, the .min.js versions of my JS files weren't actually in the project. They were created successfully on each build...but they didn't show up in the Solution Explorer. So, I put them there and now it works okay.
Now my problem is that I don't want to see my Release build's .min.js files in Solution Explorer...ever. Do I just have to deal with it or is there something I am missing?
So, the answer was to "Add > Existing Item" to the project to include the minified versions of my scripts in the project.
As for the other question: "ow my problem is that I don't want to see my Release build's .min.js files in Solution Explorer...ever. Do I just have to deal with it or is there something I am missing?"
I'm going to go with "I just have to deal with it" as the answer.

How do I add CRRedist2008_x86.msi to Visual Studio Deployment Project?

I need to add CRRedist2008_x86.msi to my deployment project as it is a requirement for my app. However, I want it to run automatically. I don't want it to be just added as a file and then the user has to click on it for it to run after my app installs. Can someone guide my on how to do this? It seems like it should be very easy but for some reason I am missing something.
What you need to do is set it up as a "merge module" in your deployment project. Instead of the .msi, find the.msm file that should be available on the CR website. Then in your deployement project, right click the Project and select Add->Merge Module. Browse for the file and you are set.
When the installer runs, it will automatically unpack the crystal reports related items and install them for you. You may also need a key file, depending on the licensing of the application involved.

Resources