Friday, December 13, 2013

WordPress Plugin: Royal Slider

I was working with the Royal Slider plugin on a WordPress site. I needed to allow the slider show images and SWF, however, there did not appear to be any option to allow a SWF file to be dragged and dropped even as an image. Sometime I forget the simplest things. I was trying to read the documentation, scour the suppport forum for a way that the slider would allow me to do this. I am mean it is pretty simple HTML markup -- HA! Yes, and there it is, the Royal Slider allows you to put HTML Markup for a slide. So that is all you have to do insert your object markup there..
  1. <div id="flashContent" style="text-align:center">
  2. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="test" align="middle">
  3. <param name="movie" value="http://test.swf"/>
  4. <param name="quality" value="high" />
  5. <param name="bgcolor" value="#ffffff" />
  6. <param name="play" value="true" />
  7. <param name="loop" value="false" />
  8. <param name="wmode" value="transparent" />
  9. <param name="scale" value="showall" />
  10. <param name="menu" value="true" />
  11. <param name="devicefont" value="false" />
  12. <param name="salign" value="" />
  13. <param name="allowScriptAccess" value="sameDomain" />
  14. <!--[if !IE]>-->
  15. <object type="application/x-shockwave-flash" data="test.swf" width="550" height="400">
  16. <param name="movie" value="test.swf" />
  17. <param name="quality" value="high" />
  18. <param name="bgcolor" value="#ffffff" />
  19. <param name="play" value="true" />
  20. <param name="loop" value="false" />
  21. <param name="wmode" value="transparent" />
  22. <param name="scale" value="showall" />
  23. <param name="menu" value="true" />
  24. <param name="devicefont" value="false" />
  25. <param name="salign" value="" />
  26. <param name="allowScriptAccess" value="sameDomain" />
  27. <!--<![endif]-->
  28. <a href="http://www.adobe.com/go/getflash">
  29. <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
  30. </a>
  31. <!--[if !IE]>-->
  32. </object>
  33. <!--<![endif]-->
  34. </object>
  35. </div>

Friday, September 6, 2013

SQL Server Reporting, are you having fun yet?

If you are visiting my blog today in search of help because you are configuring a SQL Server Reporting server, I hope this helps. I have had to setup the same reporting server about 3 times now. This last time because I bought a new dev PC and the client decided to use a custom configuration instead of the kinda standard setup that Reporting Services has.
Setting up a Report Server requires careful detail to permissions. Yes, love, love, love permissions.
Here are a few pointers:
Say you are setting your own local copy for dev purposes, and you get some sort of pop-up 'Access Denied' permission, right as you try to 'Start' you ReportServer, you may want to check your folder permissions on the 'Reporting Services', for myself I was using the 'Network Service' account to run the show and somehow the permission on the folder was all of the sudden gone after working for some time. IDK but make sure you go to the highest folder 'Reporting Services' and allow your selected user 'Full Control' on that folder!
Sometimes you may need to create a Login to run reports, so go into SQL Server Management Studio, create a Login with a SQL Server authentication and a password you can remember, give it permissions to the database you are trying to get a report to run on. Sometimes you may need to give it 'Execute' permissions on Store Procs too! This user may even come in handy as the user that a 'Shared Data Source' can use. Since I am just doing this for dev purposes, I have found this is the easiest way to get passed permission errors....
Now, let say you got the ReportServer to start but it is still acting funny. You get a 500 Service error when you try to visit the ReportServer URL. Go to the log files and check into errors there.
If you see this error:
ERROR: AppDomain ReportServer_MSSQLSERVER_0 failed to start. Error: Invalid syntax on line 166 - 'Expected > character.'.
Please inspect your config files, make sure you have all begin and end tags correct (and double check all those attributes!). I was actually missing an end tag and this error kept coming up. I was editing the config files in TextPad so it was hard to spot. Once I opened them in Visual Studio, it was much easier to identify!
Ok. So you have stuff running, and you are trying to run as the 'Integrated Security' for stuff, you visit the Report Server URL, it keeps prompting you for a login or maybe permission, try this. Open IE Explorer as 'Run as Administrator' then try again. This is one case where you will have to drop FireFox/Chrome. IE plays better here. I suppose since it is a MS product....
Hope that helps! It is always a headache setting up a report server! I feel for you. Just do little steps at a time, DOUBLE-CHECK! It is very finicky one little thing and it doesn't work!

Wednesday, September 4, 2013

GoDaddy - Configuration to allow PHP in HTML files

I had an existing site with a lot of existing html files that also needed to execute php. However, when configuring anything, there may be numerous ways to solve the same problem. You can find this question on many sites and some solutions work for people and some do not. I found I had to keep trying slightly different versions until one finally worked. It all depends on the particular hosting service you are using, the various settings your particular site has..on and on.
On my local server, I could put the following at the top of my .htaccess file and it ran the php inside the .html files fine:
AddHandler x-httpd-php .php4
AddType application/x-httpd-php .html
On the GoDaddy server, the configuration was a bit different:
Options +ExecCGI
AddType text/html .html
AddHandler x-httpd-php5 .php .html
I had struggled with this for awhile, this article gave me the best hint:
http://www.sandisviksna.com/blog/2011/10/16/php-in-html-with-godaddy/
which recommended this:
Options +ExecCGI
AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php5 .php .htm .html
So I kept tweaking that and it worked. Honestly, I have not completely read the Apache manual on what exactly these directives mean. I am one of those people that is willing to use what works without really knowing the details because I have to keep working. The client want stuff done and right now I do not have the leisure time to research the details...I hope this helps someone else!

Thursday, June 27, 2013

ASP.net Web.config use older DLL

I ran into a situation where the web server I was publishing too had an older DLL file than the DLL file I had used to compile on my local server. So when I published to the server it kept looking for the new version rather than just using the one available on the server.
You can specify the version to use in the web.config file. However, it is a bit deceiving when you want to go backwards meaning I want to user version 1.0 but the dll I used to compile was version 2.0. The tag uses the term oldVersion and newVersion. I think most people want to go in the direction from old to new, but in my case it was new to old.
That kept tripping me up. I kept specifying the old and new version thinking it would understand me...no, i had to say the old version is 2.0 and the new version that should be used is 1.0.
Maybe the tags should have been versionToUse and versionToIgnore...
Here is my sample web.config snippet:
  1. <runtime>
  2.         <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  3.          <dependentAssembly>
  4.          <assemblyIdentity name="DLLname" culture="neutral" publicKeyToken="a7a0b3f5184f2169"/>
  5.          <codeBase version="8.0.0.5" href="FILE://C:/windows/assembly/GAC_MSIL/DLLname"/>
  6.          <bindingRedirect oldVersion="8.1.2.3" newVersion="8.0.0.5" />
  7.          </dependentAssembly>
  8.         </assemblyBinding>
  9.     </runtime>

Wednesday, June 5, 2013

IvyCat Testimonial Rotator WordPress Plugin

I have worked a bit with WordPress over the past year. It is an interesting template-type application. I don't know the actual term for what it is but it is based on PHP. The nice thing about it is that there are so many pre-written modules available some free, some you have to pay for. The selection is nice and you can always modify the code.
Recently I needed to create a Testimonial Rotator. I sampled the 8-10 free ones available. The one I ended up selecting was the IvyCat Testimonial.
It was the best one that could pretty much be used out of the box. I tweeked it just a bit to fit into the page I needed. It was easy to use, pretty flexible, fast and I would totally recommend it!

Thursday, May 23, 2013

Setting up a SqlCacheDepdency

The great thing about setting up a SqlCacheDepdency is that once it is working, you never really have to do anything with it. In my case, it has been roughly 5 years since I set one up...the downfall? I can't remember all the little steps it takes to set it up. And it is not easy. It has to be precisely setup....precisely!
Today, I wanted to beat my PC into oblivion. Seeing that was not really going to help, I had to research...and research. Here are the steps. Though not clear because when you try 1 million things, you don't really know what was needed and what was not...
Details, asp.net, SQLServer 2008R2
1. NEEDED, Enable Broker
ALTER DATABASE myDbName SET ENABLE_BROKER with rollback immediate;

2. [Not SQL2008R2] Needed for lesser versions...I think. I will add this just in case you need it:

GRANT CREATE PROCEDURE TO "NT AUTHORITY\NETWORK SERVICE"
GRANT CREATE QUEUE TO "NT AUTHORITY\NETWORK SERVICE"
GRANT CREATE SERVICE TO "NT AUTHORITY\NETWORK SERVICE"
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO "NT AUTHORITY\NETWORK SERVICE"
GRANT SELECT ON OBJECT::dbo.TableName TO "NT AUTHORITY\NETWORK SERVICE"
GRANT RECEIVE ON QueryNotificationErrorsQueue TO "NT AUTHORITY\NETWORK SERVICE"


3. Setup Global.asax- Application_Start:

System.Data.SqlClient.SqlDependency.Start(connectionString);

4. Setup Cache code:
  1. ConfigurationInfo configInfo = null;
  2. System.Web.Caching.SqlCacheDependency dependency = null;
  3. if (Cache["Config"] == null)
  4. {
  5. try
  6. {
  7. cacheConfigInfo = GetConfiguration(out dependency);
  8. }
  9. catch {}
  10. finally
  11. {
  12. Cache.Insert("Config", cacheConfigInfo, dependency);
  13. }
  14. }
  15. ....



5. VERY Important: You must attach the SqlCacheDependency to the SqlCommand before you execute the command:

It must be a simple query (no crazy aggregates), it can be in a stored procedure.
If it is in a stored proc qualify the db name like this :dbo.MyTableName

  1. public ConfigurationInfo GetConfiguration(out SqlCacheDependency dependency)
  2. {
  3. ConfigurationInfo configInfo = null;
  4. SqlConnection conn = new SqlConnection();
  5. conn.ConnectionString = SQLHelper.DbConnectionString;
  6. SqlCommand command = new SqlCommand("up_GetConfig", conn);
  7. command.CommandType = System.Data.CommandType.StoredProcedure;
  8. dependency = new SqlCacheDependency(command);
  9. using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.DbConnectionString, "up_GetConfig"))
  10. {
  11. if (reader.Read())
  12. {
  13. configInfo = new ConfigurationInfo();
  14. configInfo.Id = reader["ID"] == DBNull.Value ? 0 : (int)reader["ID"];
  15. ....
  16. }
  17. }
  18. return configInfo;
  19. }


I hope that helps....I am sure in another 5 years I might need to reference this again!

Wednesday, May 8, 2013

Blogger SyntaxHighlight

I have been trying to use SyntaxHighlighter for months now and it has been quite cumbersome. I don't post every week so every time I have to post code, I have to go back to remember the steps to post formatted code.
Plus I thought I had added the calls to my blogger template but now they are missing? very strange. maybe for some odd reason i decided to take out something i wanted to use from my template....OR MAYBE NOT! i don't know if blogger decided to remove the calls or if they did an update that took out my calls but they are not there...
Overall, I pretty much regret selecting Blogger as my blogging tool. If I could go back in time and start with a blogging tool that was more programmer friendly, I sooooo wish I would have. But now I am stuck in the Blogger trap....
anyhow, since SyntaxHighlighter is hard for me to remember how to use, i am trying out a new solution. http://www.syntaxhighlight.in/. This has a nice option to pop-up the code or display in text. I will see in time if this option is less time consuming to use..

Tuesday, May 7, 2013

Jquery Tab does not work in ASP UpdatePanel

I have been using Jquery Tabs a lot lately and they usually work just fine. An issue here and there. Today I had an issue when trying to put the tabs inside an ASP Update Panel. The code did not seem to work. I found this easy fix buried in some forum....so I thought I would put it in my blog to be more accessible...and it worked really...
  1. <script type="text/javascript">
  2. function pageLoad(sender, args) {
  3. if (args.get_isPartialLoad()) {
  4. //put any javascript code
  5. $('#myTabs').tabs();
  6. }
  7. }
  8. </script>

Tuesday, April 30, 2013

Classic ASP Persistent Cookie

I have not really worked with Cookies files. Recently I needed to persist a cookie for a user, however, I noticed that although I would create the cookie it would later disappear. Then I realized that it was disappearing when the browser was closed. I had not realized I was only creating an in-memory cookie that only lasted until the browser was closed.
This is how I was creating the cookie:
intNumber = 1
Response.Cookies("userCookie")=intNumber
However, what I needed it to do was last beyond the browser being closed...be persistent. In order to do that I had to add an expiration like this:
intNumber = 1
startDt=Date
endDate=DateAdd("d",365,startDt)
Response.Cookies("userCookie")=intNumber
Response.Cookies("userCookie").Expires = endDate
And that allowed my cookie file to remain until the user deleted it or it expired!

Tuesday, March 26, 2013

Running Windows XP Home Edition, need a webserver?

Who would have thought I would need to run a webserver for some classic asp code on an old Windows XP laptop...If you have not already realized this, Windows XP Home does not have an IIS option...so if you want to run classic ASP site you will have to find an alternative.
Luckily, I ran across a post that pointed me to Baby Web Server. This turned out to be just what I needed. I just needed a test area for an asp app and this worked!

Wednesday, March 13, 2013

SelectedIndexChanged firing on DataBind?

As I was looking into a GridView issue today, I came across this teeny, tiny tip. And in the back of my mind, I know this has been a problem for me sometimes, but I did not know it until I saw this posted:
Try assigning the "DataTextField" and "DataValueField" before you assign the DataSource. Doing so will prevent firing the "SelectedIndexChanged" event while databinding...
If this tip is right, BRILLIANT!

SQL Server DateDiff Calculating Year, Quarter etc

I will admit, I simply do not follow the DateDiff, DateAdd functions that SQL provides for date calculation. It is too complex for me! However, I have had to use it for reporting year-to-date, quarter. While I am happy they provide these to make calculations easier, I just don't dig it.
I did find this 'SQL Tip of the Day' article very helpful.
Now, for posterity and my own future reference, if that link ever goes away I am listing them here too:
Usage #1 : Calculate Age
DECLARE @BirthDate DATETIME = '1932/06/12' SELECT DATEDIFF(YEAR, @BirthDate, GETDATE()) - CASE WHEN MONTH(@BirthDate) < MONTH(GETDATE()) OR (MONTH(@BirthDate) = MONTH(GETDATE()) AND DAY(@BirthDate) <= DAY(GETDATE())) THEN 0 ELSE 1 END AS [Age]
Usage #2 : Get Date Part of a DATETIME Value
SELECT DATEADD(DD, DATEDIFF(DD, 0, GETDATE()), 0) AS [Date Part Only]
Usage #3 : Get First Day of the Month, Quarter and Year SELECT DATEADD(MM, DATEDIFF(MM, 0, GETDATE()), 0) AS [First Day of the Month]

SELECT DATEADD(Q, DATEDIFF(Q, 0, GETDATE()), 0) AS [First Day of the Quarter]

SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0) AS [First Day of the Year]

Usage #4 : Get Last Day of the Month, Quarter and Year
SELECT DATEADD(MM, DATEDIFF(MM, 0, GETDATE()) + 1, 0) - 1 AS [Last Day of the Month]

SELECT DATEADD(Q, DATEDIFF(Q, 0, GETDATE()) + 1, 0) - 1 AS [Last Day of the Quarter]

SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0) - 1 AS [Last Day of the Year]

Usage #5 : Get First Day of the Following Month, Quarter and Year
SELECT DATEADD(MM, DATEDIFF(MM, 0, GETDATE()) + 1, 0) AS [First Day of Next Month]

SELECT DATEADD(Q, DATEDIFF(Q, 0, GETDATE()) + 1, 0) AS [First Day of Next Quarter]

SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0) AS [First Day of Next Year]

Usage #6 : Get Last Day of the Following Month, Quarter and Year
SELECT DATEADD(MM, DATEDIFF(MM, 0, GETDATE()) + 2, 0) - 1 AS [Last Day of Next Month]

SELECT DATEADD(Q, DATEDIFF(Q, 0, GETDATE()) + 2, 0) - 1 AS [Last Day of Next Quarter]

SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 2, 0) - 1 AS [Last Day of Next Year]

Usage #7 : Get First Day of the Previous Month, Quarter and Year
SELECT DATEADD(MM, DATEDIFF(MM, 0, GETDATE()) - 1, 0) AS [First Day Of Previous Month]

SELECT DATEADD(Q, DATEDIFF(Q, 0, GETDATE()) - 1, 0) AS [First Day Of Previous Quarter]

SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) - 1, 0) AS [First Day Of Previous Year]

Usage #8 : Get Last Day of the Previous Month, Quarter and Year
SELECT DATEADD(MM, DATEDIFF(MM, 0, GETDATE()), 0) - 1 AS [Last Day of Previous Month]

SELECT DATEADD(Q, DATEDIFF(Q, 0, GETDATE()), 0) - 1 AS [Last Day of Previous Quarter]

SELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0) - 1 AS [Last Day of Previous Year]

Thursday, January 24, 2013

FireBug Debug Dynamic Script

If you are familiar with debugging Javascript using FireFox's FireBug, then you may run into difficulty debugging dynamic script. Although you can set a breakpoint in the script the debugger never pauses on it. You will need to add the statement 'debugger' to the area that you want to debug like this:
function junk(){
  debugger;
  var s = "test";
}
Hope that helps.