Thursday, November 16, 2017

Failed to initialize sqlcmd library with error number -2147024809

Add @execute_query_database = 'dbname' to the list of variables or dbname.dbo.tablename to the query instead of tablename

Monday, November 28, 2016

Stop Windows 10 from rescheduling restarts

I found these two links to stop windows from scheduling the restarts:

http://superuser.com/questions/957267/how-to-disable-automatic-reboots-in-windows-10

and

https://superuser.com/questions/973009/conclusively-stop-wake-timers-from-waking-windows-10-desktop/973029#973029

I used the post from jakethedog that disabled the task in the task scheduler.

Monday, April 18, 2016

c# mvc autocomplete list

I had this challenge and I had to modify several solutions to get what I wanted. This is what worked for me:

Controller had this function:
[AcceptVerbs(HttpVerbs.Post)]
        public JsonResult Create(string Prefix)
        {
            var agency = (from N in travel_agencies.ToList()
                          where N.travel_agent_name.ToLower().StartsWith(Prefix.ToLower()) || N.travel_agent_id.StartsWith(Prefix)
                          select new { N.travel_agent_name });
            return Json(agency, JsonRequestBehavior.AllowGet);
        }

the view had this:
$(document).ready(function () {
   $('#station_id').autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: "@Url.Action("Create", "ChargeBacks")",
                        type: "POST",
                        dataType: "json",
                        data: { Prefix: request.term },
                        success: function (data) {
                            response($.map(data, function (item) {
                                return { label: item.travel_agent_name, value: item.travel_agent_id };
                            }))
                        }
                    })
                },
                messages: {
                    noResults: "", results: ""

                }
            });
 });

the html element was:

<input type="text" name="station_id" id="station_id" class="form-control" />

Monday, March 28, 2016

Hire Me!

Hi all,

If you need someone to maintain, edit your website, I am the person. I am a programmer with over 9 years experience in web programming, database design. I work with php, c#, asp.net, mysql, mssql, codeigniter, phpmyadmin, wordpress, drupal, joomla, etc. 

I can allow your contact form to send emails to you and make your static website dynamic (reading information from a database).

Not sure what you want, send me an email so we can start the discussion.


Thursday, February 18, 2016

Dynamic sql returns int instead of resultset

I had to create a stored procedure that was created dynamically. It so happened that when I tested it in SQL server, it ran, producing the results. When I implemented in and called it from a stored procedure, the return value was an int. After googling, i found a solution that worked. I had to create the stored procedure to produce similar results then import in into the application. Then, I went back and edited it to return the results that I wanted it to produce.

I found the trick here: http://www.techdreams.org/microsoft/fixing-linq-to-sql-issue-stored-procedure-definition-returns-int-instead-of-resultset-2/2752-20090614


Unable to cast object of type 'Data' to type 'System.IConvertible'

I came upon this error when developing an application. I was using a foreach loop to dynamically create a select list. It so happened that I was not looping on the result without point to value in it.


So instead of just using @y i had to use @y.name in the select option

Sunday, October 18, 2015

Limited or no WIFI after upgrading to Windows 10

I upgraded my laptop to Windows 10 yesterday and everything worked fine except for the WIFI and I couldn't figure out what the problem was. I found some commands to run which did not solve the problem. I figured it was the antivirus I was using so I stopped it and that still didn't solve the problem. I found several drivers; some installed and some didnt, that still didn't work.

Since the WIFI wasnt working on, I had to be using my phone. After much googling, a thought came to me to uninstall the antivirus. I was using COMODO which also has a internet security module. During the uninstall, the Limited icon left the WIFI signal. I tested it and it was working fine. So, if anyone has this problem, try uninstalling the antivirus that is installed, if it was installed from before the upgrade.

Monday, October 5, 2015

Remove hash # from url in angular js

The $location is a service component in AngularJs. This is what will be used to remove the hash from the urls. In the config function where the routing is done, inject the $location variable and set the html5Mode to true.

var app = angular.module('mainCtrl', ['ngRoute'])
            .config(config)
            .run(run);

config.$inject = ['$routeProvider', '$locationProvider'];
    function config($routeProvider, $locationProvider) {      

        $routeProvider
        .when( '/', {
            templateUrl: 'views/login.view.html'
        })

        .when( '/home', {
            templateUrl: 'views/home.html',
            controller: 'HomeCtrl'
        })

        .otherwise({
            redirectTo: '/'
        });

        $locationProvider.html5Mode(true);
    };

For this to work, you will have to set the base url. This can be done by putting the  in the head of the html file. Remember to include the name of the folder if you have all the files in a folder. Example: 

That will remove the hash from the urls.

Sunday, October 4, 2015

Freelance Developer

It was from this same blog that I got my first freelance project...that was years ago. I had been working with P4A and had posted some code samples from projects that I had worked on and someone who found my blog had asked me for assistance on a project.

This just came to me last night that, since I am at home and I have some amount of free time on my hands that I should probably post some more code samples. So, I'll be doing that as often as I can. I will post code from PHP, JavaScript, MySQL, AngularJS...pretty much anything. I have knowledge of and experience with intel XDK, CodeIgniter, P4A...and I will challenge myself to learn something new. So, I am available for freelance projects.

Monday, September 7, 2015

Google chrome has stopped working

I have a laptop that is just about a week old and Google chrome has been giving trouble starting. I tried uninstalling and reinstalling several times, deleting left over registry items and it still would not work. I found a solution that worked but has left me still wondering why the original would not work.

What I did was to rename the exe file in the chrome location folder. So...

  1. right click on the icon on the desktop
  2. go to properties
  3. click on "open file location"
  4. rename the "chrome.exe" file to something like "chromer.exe"
  5. back in the properties window, change the file name also in the target section
  6. click "ok"
try opening chrome now and it should work. 

you may see that the original icon does not show any more, this can be changed by going back to the location of the chrome exe file and 
  1. right click on the file
  2. click on send to -> desktop (create shortcut)
  3. rename file to what you want
and that's it.

Wednesday, August 26, 2015

joomla articles opening on home page news show pro sp2

This article helped me with using news show pro sp2 on joomla and article links opening with the same layout as that of the home page: http://www.joomshaper.com/blog/why-module-links-are-opening-inside-the-frontpage

Friday, August 21, 2015

Error displaying the error page: Could not find template "".: Could not find template "".

I encountered this error when I was working on a project and after searching and searching, I decided to check the database and realized that all I had exported from the database was the structure and not the structure and the data. That was what caused the error for me.


Wednesday, February 18, 2015

Clear attachments from previous email when sending with Codeigniter

I had the problem of sending multiple emails with attachment and having the attachment from a previous email included in the next email when using the codeigniter framework. Even though I searched the manual and included the clear option, the problem still persists. After doing some research, I found out that I had to include the TRUE option in the clear function: $this->email->clear(TRUE); This is what solved it for me.

Wednesday, February 4, 2015

PHP Array to String conversion Codeigniter

I was having this problem where I was doing an update batch to my db and I was getting the error of array to string conversion. The funny thing was that the db was being updated. After doing some research, I found out that there was a problem with the DB_active_rec.php file in Codeigniter, on line 1407.

Change $not[] = $k.'-'.$v; to $not[] = $k2.'-'.$v2 and the problem is solved.

Wednesday, December 3, 2014

Using include include_once print number 1

If in writing your code in php and you are using the include or include_once and the number 1 is printed also, it means that you are using the echo with the include or include_once statement.

So....

if you have

echo include 'foo.php' or echo include_once 'foo.php', remove the echo so it becomes
include 'foo.php' or include_once 'foo.php'

if you are using the short_open_tags, eg:

<?= include_once 'foo.php'?> or <?= include 'foo.php'?>, remove the echo, in this case its the '=' equal sign so it becomes:

<? include_once 'foo.php'?> or <? include 'foo.php'?>

Sunday, November 30, 2014

codeigniter You did not select a file to upload.

This occurs because the field name is missing from the do_upload function.

if($this->upload->do_upload()){
            $data = array('upload_data' => $this->upload->data());
            echo "
";print_r($data);

            //$this->load->view('upload_success',$data);
        } else {
            $error = array('error' => $this->upload->display_errors());
            echo "
";print_r($error);

            //$this->load->view('file_view', $error);
        }

The above code should be:

if($this->upload->do_upload('flyer')){
            $data = array('upload_data' => $this->upload->data());
            echo "
";print_r($data);

            //$this->load->view('upload_success',$data);
        } else {
            $error = array('error' => $this->upload->display_errors());
            echo "
";print_r($error);

            //$this->load->view('file_view', $error);
        }

Add the name of the file field in the do_upload function.

Wednesday, August 13, 2014

HTML5 mobile app page transition flashes/flickers

To solve the flickering of page transitions using HTML5 in mobile developing, set the page transition to none either in the head of your index file:

$(document).bind("mobileinit", function(){
  $.extend(  $.mobile , {
   defaultPageTransition: 'none'
  }); 
}); or in your javascript file:

$(document).bind( 'pageinit', function(event){
    //set defaults
    $.mobile.defaultPageTransition = "none";
});

Tuesday, July 15, 2014

Show create table sql command

Run this command to show the create table sql command:

SHOW CREATE TABLE ;

Get size of database

You can get the size of a specific database by running this command:

SELECT table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
WHERE table_schema = "";

If you want to show  the size of all databases on a server, then use this command:

SELECT table_schema "Data Base Name",
SUM( data_length + index_length ) / 1024 /
1024 "Data Base Size in MB",
SUM( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;