Wednesday, August 2, 2017

SQL Server - Find Recently Changed Objects

There are times when we need to find out what all objects we made changes to in our database.
This is mostly important when we are developing and making changes on the go in the database, later only to realize that we lost track of what all objects we have changed, thereby loosing some of the changes to be moved to production.

SO here is a query that would give you the list of all objects changed since a certain time. The query could be modified to suit your needs.


1
2
3
4
5
Select * 
From sys.objects 
Where (type = 'U' or type = 'P') 
And modify_date > dateadd(d, -30, getdate()) 
Order By modify_date DESC


This query would return "TABLES/PROCEDURES" which have been changed in last 30 DAYS.
There are other similar variants using "m" for MONTHS instead of "d" for days and so on.

Sunday, February 21, 2016

Debugging Phonegap Apps on Emulators

Just recently started developing Mobile Apps and the start was with the Hybrid Apps using Phonegap.

Straight away I hit the roadblock as there were a lot of JS Errors. I could see that there were errors but unlike a web app, I did not have the luxury to hit F12 and open up the console to watch for all the errors in the console of the Chrome.

So what to do ???

Here is the answer...

1. Open CHROME on your desktop.
2. Navigate to "chrome://inspect"
3.  Check the Box "Discover USB Devices"

This would show a list of all the available Devices, including the emulators also.

Click on INSPECT for any device that you need and viola !! You have the console showing all errors for your device/emulator.


Hope this helps someone.


Thanks
Ashutosh

Saturday, February 20, 2016

Config.xml not found by Visual Studio Debugger (Ripple)

At times, while developing hybrid apps using HTML5 and JS with Apache Cordova tools for visual studio, we face this issue when the Visual Studio debugger is unable to find the config.xml file.

The reason for this is that visual studio wants this file to be present at the root of the project where as PhoneGap wants this to be at the root folder of the web app (WWW folder in visual studio project).

The solution to this is simply copying the file over from the original location to the WWW folder.

This could also be done by adding the below tag to the JSProj file.


1
2
3
<target name="AfterBuild">
    <copy continueonerror="false" destinationfolder="www" sourcefiles="config.xml"></copy>
</target>





Hope this helps.

Wednesday, July 15, 2015

Enable OLE Automation in SQL Server

In order to enable OLE Automation, run the following SQL Commands.


sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO

Thursday, December 4, 2014

Browsable / DesignerSerializationVisibility / EditorBrowsable

There are a lot of Attributes that come to help us all along when we develop custom controls for ASP.NET.

Here are a few important ones that would perform some basic operations for us during development.

These are more useful at design time then actual render time.


//This attribute when true shows up the property in the Properties Grid for a control[Browsable(true)] 
//This attribute sets whether the property would be available to VisualStudio Code Editor Intellisense.[EditorBrowsable(EditorBrowsableState.Never)] 
//This attribute sets whether the property would be serialized in the Designer HTML View or not.[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]


Explore the options available with these enums and their effects to know more on those attriutes.

IMP - There could be times when changing these attributes would not have any effect. 

Keep Calm :) .

This could be because of Visual Studio caching the intellisense schema and displaying the cached schema for you.

Simply clear the cache by deleting all the files in 
"C:\Documents and Settings\[YOUR_USER_NAME]\Application Data\Microsoft\VisualStudio\10.0\ ReflectedSchemas"

or whereever your schema files are located.


Further, another important aspect is that even when you do all this, the added custom property would be available to you at design time as well as code behind. However this property would not be rendered with the page and as a result, it would not be available at the client side for any operation.

Usually this is not required but in case you need that property to be available to you client side as an attribute, all you need to do is overwrite the AddAttributesToRender method.


// Overriding the AddAttributesToRender Method because we need to add the custom       
// properties and there values to its control html so we can use access them on        
// Client Side using JavaScript        
protected override void AddAttributesToRender(HtmlTextWriter writer)        
{            
             writer.AddAttribute("PropertyName", this.PropertyName);
            // Calling Base Class AddAttributesToRender Method                 
            base.AddAttributesToRender(writer);       
} 

Saturday, October 4, 2014

ImageButton PostbackUrl not working (DoPostBackWithOptions)

This is a common problem.

I copied over a working code from my old project into this new project and it stopped working.

No postbacks occuring. When I did view source, the source for the old page (working) and the new page (not working) were exactly the same for these controls.

The image button uses DoPostBackWithOptions

So I started looking for help related to DoPostBackWithOptions.

Finally figured out. The issue being multiple instances of "FORM" being created.

If you have more than one forms on the page, ASP.NET does not know which one to post to and stays on the safer side by not posting to any ( :) )

Remove all but one form tags from your page and it will start working.

Sunday, November 10, 2013

Instance Failure

This rather "Strange and UnCommon" error comes up mostly while connecting do database via your C# application.

Reason: - In your connection string, when there is a escape sequence (\), C# converts it to "\\" so that it could be treated the way it needs to.

Therefore if you provide a connection string as "DataSource=ServerName\SQL", c# automatically converts it to  "DataSource=ServerName\\SQL" and reads it the way it needs to.

However, if we actually provide the string something like  "DataSource=ServerName\\SQL" (With Double Back Slashes), then it raises this error causing "Instance Failure".

Solution: Use a SINGLE ( \ ) instead of Double ( \\ ).

Tuesday, July 2, 2013

Get a List of all Countries

This is a very common requirement that comes up to me in every alternate application that I make. I know there would be a lot of people like me who have the same issue.

At first I thought of consuming a ready made webservice that would give me the list of all countries.

Then upon further research, I found a very simple yet effective solution to my problem:

Here is a function that returns a List of Country Names.

public static List GetCountryList()
        {
            List _CultureList = new List();
            CultureInfo[] _CultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
            foreach (CultureInfo _Culture in _CultureInfo)
            {
                RegionInfo _RegionInfo = new RegionInfo(_Culture.LCID);
                if (!(_CultureList.Contains(_RegionInfo.EnglishName)))
                {
                    _CultureList.Add(_RegionInfo.EnglishName);
                }
            }
            _CultureList.Sort();
            return _CultureList;
        }

Tuesday, March 5, 2013

Only parameterless constructors and initializers are supported in LINQ to Entities

This is the error that usually come up when you try to run a LINQ Query and return an object out of this QUERY.

Something like the below example:
var query = (from c in ctx.Clients
                         where l.UserID == userid
                         select new ClientList(c.ClientFirstName, c.ClientLastName,  c.ClientEmail)
                          ).ToList();
Well the Error is Pretty much self explanatory. No Parameterized constructors are allowed for LINQ to Entities...

Workaround ?
Change your Query to something like this..
var query = (from c in ctx.Clients            
                         where l.UserID == userid
                         select new ClientList{ClientFirstName= c.ClientFirstName, ClientLastName= c.ClientLastName, ClientEmail= c.ClientEmail}
                          ).ToList();



Thursday, December 20, 2012

JQuery Autocomplete "Internal Server Error"

Hello,

This is something that is very common for all of us to encounter. I encountered this N no. of times during my work and most of the times for all new reasons then before.

Here are a few things that you could look out for:

This error clearly mentions that it is a "Server Error" which means we could not get a proper response back from the server. So chk for these....

1. Make sure you are calling to the correct WebService and correct Method of the webservice.

2. The make sure you pass the correct name of the parameter as requested by the WebMethod.

3. The method should be marked as WebMethod in the WebService.

4. Debug through your Webmethod to see if it fails somewhere.

5. If you are not at all getting the Webmethod to hit (Which was precisely my case), then look for the
    [System.Web.Script.Services.ScriptService]
tag above your asmx.

To allow this Web Service to be called from script, using ASP.NET AJAX, you need to have the  following line on top of your WebService declaration

    [System.Web.Script.Services.ScriptService] 

Hope this helps...