Thursday, November 12, 2015

SQL Server: Save Database Locally

If you have a database up in the cloud or elsewhere and want to make a local copy, you start by opening up SQL Server Management Studio (this is 2014 but should be the same/similar for other versions).

Login to your local server. I used SQL Express, so my login is Windows Authentication and the server name is localhost/SQLEXPRESS. Also make sure this is running if you check in your Services on your machine.

Login to your online server. You need those credentials from your company or whatnot.

Now, start by right clicking on Datbases on your online server and hitting Export Data-tier application.

Hit Next.
Save locally somewhere. I just made a Db folder under my C drive to make it easy to find. It will save a BACPAC file.

Now, right click on Databases on your local server and hit Import Data-tier application. Find your BACPAC file you just made.

Find the BACPAC file you saved.

Hit Next and finish up with this dialog and you should have a local copy imported into your local server.

Add your local DB to your connection string config file.

Installing SQL Server && .NET 3.5 on Windows 10

Recently at work, I upgraded to Windows 10. Obviously, I needed SQL Server. Interestingly all versions I tried (2012, 2014, and 2016) are dependent on .NET 3.5. Even more interestingly, Windows 8 and Windows 10 do not come stock with .NET 3.5.

Anytime I tried to install SQL server, I would get a missing .NET 3.5 error.

When I try to install .NET 3.5 I had the following error: 0x800f081f missing source files.

I tried this and it failed, many times:
  1. Open a command prompt with administrator user rights (Run as Administrator) in DOS BOX type gpedit.msc
  2. Local Computer Policy -> Admin Templates -> System -> Specify settings for Optional Component install and component repair (way near the bottom of the right frame)
  3. Check the “Contact Windows Update Directly” box and set policy to Enabled.
  4. Close gpedit
  5. *Try this: Type in the dos box: DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
  6. Or check in Control Panel and you can now check the .net 3.5 box and it should download
(I also tried using a USB drive with the source files and that failed.)

What did work for me:
  1. On this page (note screenshot above with photo): https://www.microsoft.com/en-us/software-download/windows10, hit Download Media Creation Tool.
  2. On my Windows 10 laptop, I opened this file, made a .ISO of my windows 10.
  3. I mounted said .ISO onto the E: drive (right click .ISO and click Mount).
  4. I ran command prompt as an admin.
  5. Then I ran this in command prompt (Replace E with whatever your mounted drive for Windows ends up being).
DISM /Online /Enable-Feature /FeatureName:NetFx3 /Source:E:\sources\sxs /All /LimitAccess

.. and it made me restart. And then it appeared to work. For some reason having it mounted locally worked.

On top of this, I was installing SQL Server 2014 and ran into another snag. I got stuck on Install watsonx86_cpu32_action, for a long long time.. suspected somethng was wrong and read a website here. Based on the suggestions, I went into Task Manager and had to End Task on some Windows Installer processed under the Background Processes.. and then it caused it to get past the watson freeze.

Wednesday, November 11, 2015

Angular JS: $.emit and $.on


In Angular, you sometimes need the scope/functions of another controller to be triggered by something in one controller.

For example, say you have a controller for a navigation page (Controller 1) and a Map page (controller 2) that contains changing maps. You want the navigation page to have a button that changes the map, but all of your stuff to control the Map page is in the Map controller. You can't hit those scope items or those methods.

So, you can have an onclick on the button on the Navigation page that hits the Controller 1 changeMap functions, which will $.emit 'changeMap' out.. where in Controller 2 there is an event listener $.on waiting for this to be triggered, and it will reroute you to the changeMap_Handler.

Controller 1: Navigation Page Controller Controller 2: Map Page Controller

Tuesday, November 3, 2015