Showing posts with label Web. Show all posts
Showing posts with label Web. Show all posts

Wednesday, 1 May 2013

SSRS 2008 R2 on Windows 8… Cannot log in

I recently installed SQl Server 2008 R2 with Advanced Services on a Windows 8 Box. However, when I tried to log into the ReportManager of SSRS, I found that it wouldn’t accept my Username and Password Combo.

After some searching, I found this poston Stack Overflow, which explained it nicely;

http://stackoverflow.com/questions/14433068/user-does-not-have-required-permissions-ssrs-2008-on-windows-8

Turns out, that as standard, the Administrator account isn’t active in Windows 8, and needs to be turned on. More annoyingly, this means that SSRS needs to be uninstalled, and reinstalled using the hidden Administrator account.

The steps I took to finally resolve were;

  1. Uninstall SSRS Node COMPLETELY by going to control panel>SQL Server 2008>Remove>Check Reporting Services
  2. Enable default admin account: command prompt>run as administrator>net user administrator, hit enter.
  3. New line: net user administrator /active:yes
  4. Reboot
  5. Logging in as default administrator
  6. Setup a Password of your Choice
  7. Reinstall the SSRS Node
  8. Install SP3 as administrator
  9. Go to IE.exe DIRECTLY in Windows 8: C:\Program Files\Internet Explorer\iexplore.exe>Run as administrator.
  10. Go to http:// (servername)/Reports
  11. You SHOULD now be able to finally see site settings. NOW YOU CAN FOLLOW everyone's directions of adding YOUR USER under site settings. Also go to folder permissions and add the user as a default here as well.
  12. (optional) For safety I would hide the default admin account now by using step 2 but substitute /active:no in.

SSRS 2008 R2 Reports are blank in Chrome

I stumbled across this apparently well documented problem today, where my SSRS 2008R2 Report was showing up fine in IE, but blank in Chrome;

http://stackoverflow.com/questions/5968082/ssrs-2008-r2-reports-are-blank-in-safari-and-chrome

It seems as though the main Div Tag uses IE compatible only Overflow styles, which Chrome doesn’t interpret well.

I found a nice blog post here which explained how to work around this issue;

http://grumpydba.blogspot.co.uk/2012/02/sql-2008-r2-report-doesnt-show-on.html

The Short and curlies of it are;

Connect to your Reporting Services server, and find the relevant ReportingServices.js file - this will probably be somewhere like "C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager\js\ReportingServices.js", or on a 64 bit machine, "C:\Program Files (x86)\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager\js\ReportingServices.js"


First up, take a copy of this file - let's not be silly here and assume this is a 100% foolproof solution!
Next, edit this file in notepad. Do a quick search for PageLoad, to ensure no-one else has already hacked applied this fix, then jump to the bottom of the existing text.
Simply append the following code:

function pageLoad() 
{
    var element = document.getElementById("ctl31_ctl10");
    if (element)
    {
        element.style.overflow = "visible";
    } 
}


Save the file, and restart Reporting Services - you should now find that Chrome displays your reports again.


You’ll need to find the correct ElementId, by viewing the Source of the report in Chrome. If you search for “VisibleReportContent”, you should find something like “VisibleReportContentctl31_ctl09”. Where the “ctl31_ctl09” is the ElementID you’re looking for!

Thursday, 24 January 2013

Enabling MS SQL Extensions in WAMP

While working on a problem recently, I needed to enable the MS SQL extensions in WAMP. It turned out to be more complicated than simply hitting the checkbox in the Extensions menu…

I found this great post which explained the process.. http://forum.ragezone.com/f724/get-wamp-work-mssql-673301/

The basic Idea is;

  1. Download ntwdblib.dll: HERE
  2. Click on the WAMP icon -> PHP -> PHP Extensions then check “php_mssql” and “php_pdo_mssql”. (Wamp will restart and give you few errors, ignore them)
  3. Restart WAMP one more time to ensure settings are saved.
  4. Finally, place ntwdblib file in the two following directories:
    wamp\bin\php\php5.3.1 (Or the directory relating to whichever version of PHP you are currently using)
    wamp\bin\apache\apache2.2.11\bin (Or the directory relating to whichever version of Apache you are currently using)
  5. Restart wampserver, and you're finished!

Hopefully this helps somebody else too!

Exporting MS SQL Table Data using PHP

I regularly export table data from MySQL using PHP, however a question on StackOverflow.com came up where the user wanted to export data from MS SQL rather than MySQL.

Handily, PHP has support for many of the same functions for MS SQL as it does for MySQL.

So with a bit of reworking I was able to come up with the following script;

<?php
    
    $servername = '.\SQLSERVER';
    $username = 'databaseuser';
    $password = 'database';
    $database = 'CriticalPath';
    $table = 'Users';
 
    if (!function_exists('mssql_fetch_row'))
    {
        $output .= "MSSQL functions are not available.<br />\n";
        exit;
    }
 
    // Connect database
    if(!$dbconnect = mssql_connect($servername, $username, $password))
    {
        $output .= "Connection failed to the host 'localhost'.";
        exit;
    } // if
        
    if (!mssql_select_db($database))
    {
        $output .= "Cannot connect to database '$database'";
        exit;
    } // if
    
    $result=mssql_query("select * from $table");
    
    $out = '';
 
    $columns = mssql_num_fields($result);    
 
    for ($i = 0; $i < $columns; ++$i) {
        // Fetch the field information
        $field = mssql_fetch_field($result, $i);
        $out .= '"'.$field->name.'",';
    }
       
    $out .= "\r";
    
    // Add all values in the table to $out.
    while ($l = mssql_fetch_array($result)) 
    {
       for ($i = 0; $i < $columns; $i++) 
       {
          $out .='"'.$l["$i"].'",';
       }
 
       $out .= "\r";
    }
    
    // Open file export.csv.
    $f = fopen ('export.csv','w');
    
    // Put all values from $out to export.csv.
    fputs($f, $out);
    fclose($f);
    
    header('Content-type: application/csv');
    header('Content-Disposition: attachment; filename="export.csv"');
    readfile('export.csv');
 
    mssql_free_result($result);
 
?>

Monday, 21 January 2013

Forcing html Input element to Numeric Only Input

While developing a shopping cart function for a client, I needed to restrict the user to entering numbers only in an Input field

I came across this handy post;

http://www.itjungles.com/javascript/how-to-use-javascript-to-force-numeric-value-in-textbox

Basically, we need to add the following function to the JavaScript section;

function isNumericKey(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) 
    {
        return false;
    }
    else
    {
        return true;
    }
}    


We then add the the following to your input element;


onkeypress="return isNumericKey(event)"


Hey Presto! You have a numeric only Input Element!

Monday, 7 January 2013

Validating an Email Address

In order to validate an email address, use the following function;

Public Function IsValidEmailAddress(ByVal EmailAddress As String) As Boolean
    Dim Expression As New System.Text.RegularExpressions.Regex("\S+@\S+\.\S+")
 
    If EmailAddress = "" Then
 
        Return True
 
    Else
 
        Return Expression.IsMatch(EmailAddress)
 
    End If
    
End Function

Monday, 15 November 2010

Shared Apache Server Directories require index page in order to access files from the web

For security reasons, Apache hosts enforce that, for a directory and it’s contents to be accessible from the web, the directory must contain an index.htm page.

This can be overridden by adding a .htaccess file with the following lines included;

ErrorDocument 401 "Unauthorized"
DirectoryIndex index.php index.shtml index.html publish.htm publish.html

Using an Apache Server to Host “ClickOnce” .net Deployment

Normally, to deploy ClickOnce applications, you would upload files to a Windows Server hosting environment. However, with the addition of a simple .htaccess file, you can host ClickOnce on an Apache based server.

Simply create a text document with the following content:

ErrorDocument 401 "Unauthorized"
DirectoryIndex index.php index.shtml index.html publish.htm publish.html
AddType application/x-ms-application application
AddType application/x-ms-manifest manifest
AddType application/octet-stream deploy

Save the file as .htaccess and upload to your deployment directoy.

The line:

DirectoryIndex index.php index.shtml index.html publish.htm publish.html

Allows the server to show the standard Visual Studio “publish.htm” file as default.