How to Generate Web Service Proxy

by Admin 12. September 2008 12:24

Simply run this command in VS command prompt

wsdl /o:MyService.cs /n:namespace.goes.here http://localhost/Service.asmx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

asp.net

Unable to connect to the remote server

by Admin 24. July 2008 16:06

(Microsoft.SqlServer.Management.UI.RSClient)

When connecting to Reporting Services (2005) using MS Management Studio I've had this message:

Connect to Server
Cannot connect to <ServerName>.

ADDITIONAL INFORMATION:

Unable to connect to the remote server (Microsoft.SqlServer.Management.UI.RSClient)

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.1.5:80 (System)

 

I could still connect to Reporting Services using Web interface.

I've noticed that for some reason Domain Controler does not translated server name to proper IP address, so quick fix was to use IP address while connecting, and everything was ok.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

SQL 2005 | Reporting Services

Failed to install KB948109 with error code 7342

by Admin 17. July 2008 08:50

When i was trying to apply this hotfix using Windows Update it failed with Error Code 7342.

Workaround for me was to download it from here and install this hotfix manually.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

SQL 2005 | Vista

How to find Object property and set it's value

by admin 16. July 2008 10:44

Sometimes you may want to find your object property and set it's value. To do this try something like this:

MyObject myObject = new MyObject(); string propertyName = "MyPropertyName"; bool myValue = true;
Type type = this.GetType();
System.Reflection.PropertyInfo property = type.GetProperty(propertyName);
if (property != null)
    System.ComponentModel.TypeDescriptor.GetProperties(typeof(MyObject))[propertyName].SetValue(myObject, myValue);

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

c#

'ProfileCommon' could not be found

by admin 10. July 2008 22:47

After publishing web project to production server i had this message:

The type or namespace name 'ProfileCommon' could not be found (are you missing a using directive or an assembly reference?)

I've deleted everything and re-published web project and now everything is ok.

Anybody knows why this is happening (sometimes)?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

asp.net

Parameterize the TOP clause in sql 2005

by admin 5. July 2008 23:26

SQL Server 2005 actually allows us to parameterize the TOP clause, using a variable, expression or statement. So you can do things like:

select top (@foo) [Column1] from [dbo].[myTable] 
 
select top (SELECT COUNT(*) FROM somewhere else) [Column1] from [dbo].[myTable]
 
select top (@foo + 5 * 4 / 2) [Column1] from [dbo].[myTable]

so we can create parameterized stored procedure with top as input parameter. In Sql 2005 it's simple:

create procedure dbo.getFoo 
    @top INT 
as 
begin 
    select top (@top) percent [column1]
        from [dbo].[myTable]         
end
go

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SQL 2005

VS SQL Server Project is restricted to what assemblies you can reference

by admin 23. June 2008 21:40

However there are ways around it:

1. Don't use the VS SQL Server Project, but just create a normal class library project, add references as per usual and then manually create your assembly through CREATE ASSEMBLY. Make sure your referenced assemblies are in the same directory as your user assembly. The SQLCLR team has released some code that automatically creates procs/functions/triggers etc. when you run the CREATE ASSEMBLY code.

2. If you want to use the VS SQL Server Project you can create the assembly you want to reference in the database before you try to reference it. I.e: do a manual CREATE ASSEMBLY against the ManagedDTS.dll

3. Use my SQL Server VS templates and deploy task. This gives you the ability to reference what you want, and still get auto deployment. However, which-ever way to go, be careful with what you are doing. You don't want some code to compromise SQL Server!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Security | SQL 2005

The easiest way to be able to create an assembly as UNSAFE/EXTERNAL ACCESS

by admin 23. June 2008 11:45

The easiest way to be able to create an assembly as UNSAFE/EXTERNAL ACCESS you can do this:

1. Mark the database as trustworthy: ALTER DATABASE db_name SET TRUSTWORTHY ON 
2. Give the login of the owner of the database the right permissions: GRANT EXTERNAL ACCESS ASSEMBLY to userlogin.

That's it. You can now create an assembly as EXTERNAL ACCESS/UNSAFE. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Security | SQL 2005

How to get cell value from OpenXml document (Excel 2007)

by admin 17. June 2008 14:34

Below you'll find code snippet for reading cell value(s) from Office 2007 Excel document.

In order to get this working you'll need to add refference to WindowsBase.dll .

sheetName="Sheet1"; addressName="E9";

public static string GetCellValue(string filePath, string sheetName, string addressName)
        {
            //  Return the value of the specified cell.
            const string documentRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
            const string worksheetSchema = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
            const string sharedStringsRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";
            const string sharedStringSchema = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";

            string cellValue = null;

            //  Retrieve the stream containing the requested
            //  worksheet's info:
            using (System.IO.Packaging.Package xlPackage = System.IO.Packaging.Package.Open(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                System.IO.Packaging.PackagePart documentPart = null;
                Uri documentUri = null;

                //  Get the main document part (workbook.xml).
                foreach (System.IO.Packaging.PackageRelationship relationship in xlPackage.GetRelationshipsByType(documentRelationshipType))
                {
                    //  There should only be one document part in the package.
                    documentUri = System.IO.Packaging.PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), relationship.TargetUri);
                    documentPart = xlPackage.GetPart(documentUri);
                    //  There should only be one instance,
                    //  but get out no matter what.
                    break;
                }

                if (documentPart != null)
                {
                    // Load the contents of the workbook.
                    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                    doc.Load(documentPart.GetStream());
                    //  Create a namespace manager, so you can search.
                    //  Add a prefix (d) for the default namespace.
                    System.Xml.NameTable nt = new System.Xml.NameTable();
                    System.Xml.XmlNamespaceManager nsManager = new System.Xml.XmlNamespaceManager(nt);
                    nsManager.AddNamespace("d", worksheetSchema);
                    nsManager.AddNamespace("s", sharedStringSchema);

                    string searchString = string.Format("//d:sheet[@name='{0}']", sheetName);
                    System.Xml.XmlNode sheetNode = doc.SelectSingleNode(searchString, nsManager);
                    if (sheetNode != null)
                    {
                        //  Get the relId attribute:
                        System.Xml.XmlAttribute relationAttribute = sheetNode.Attributes["r:id"];
                        if (relationAttribute != null)
                        {
                            string relId = relationAttribute.Value;

                            //  First, get the relation between the
                            // document and the sheet.
                            System.IO.Packaging.PackageRelationship sheetRelation = documentPart.GetRelationship(relId);
                            Uri sheetUri = System.IO.Packaging.PackUriHelper.ResolvePartUri(documentUri, sheetRelation.TargetUri);
                            System.IO.Packaging.PackagePart sheetPart = xlPackage.GetPart(sheetUri);

                            //  Load the contents of the workbook.
                            System.Xml.XmlDocument sheetDoc = new System.Xml.XmlDocument(nt);
                            sheetDoc.Load(sheetPart.GetStream());

                            System.Xml.XmlNode cellNode = sheetDoc.SelectSingleNode(string.Format("//d:sheetData/d:row/d:c[@r='{0}']", addressName), nsManager);
                            if (cellNode != null)
                            {
                                //  Retrieve the value. The value may be stored within
                                //  this element. If the "t" attribute contains "s", then
                                //  the cell contains a shared string, and you must look
                                //  up the value individually.
                                System.Xml.XmlAttribute typeAttr = cellNode.Attributes["t"];
                                string cellType = string.Empty;
                                if (typeAttr != null)
                                {
                                    cellType = typeAttr.Value;
                                }

                                System.Xml.XmlNode valueNode = cellNode.SelectSingleNode("d:v", nsManager);
                                if (valueNode != null)
                                {
                                    cellValue = valueNode.InnerText;
                                }

                                //  Check the cell type. At this point, this code only checks
                                //  for booleans and strings individually.
                                if (cellType == "b")
                                {
                                    if (cellValue == "1")
                                    {
                                        cellValue = "TRUE";
                                    }
                                    else
                                    {
                                        cellValue = "FALSE";
                                    }
                                }
                                else if (cellType == "s")
                                {
                                    //  Go retrieve the actual string from the associated string file.
                                    foreach (System.IO.Packaging.PackageRelationship stringRelationship in documentPart.GetRelationshipsByType(sharedStringsRelationshipType))
                                    {
                                        //  There should only be one shared string reference,
                                        // so you exit this loop immediately.
                                        Uri sharedStringsUri = System.IO.Packaging.PackUriHelper.ResolvePartUri(documentUri, stringRelationship.TargetUri);
                                        System.IO.Packaging.PackagePart stringPart = xlPackage.GetPart(sharedStringsUri);
                                        if (stringPart != null)
                                        {

                                            //  Load the contents of the shared strings.
                                            System.Xml.XmlDocument stringDoc = new System.Xml.XmlDocument(nt);
                                            stringDoc.Load(stringPart.GetStream());

                                            //  Add the string schema to the namespace manager:
                                            nsManager.AddNamespace("s", sharedStringSchema);

                                            int requestedString = Convert.ToInt32(cellValue);
                                            string strSearch = string.Format("//s:sst/s:si[{0}]", requestedString + 1);
                                            System.Xml.XmlNode stringNode = stringDoc.SelectSingleNode(strSearch, nsManager);
                                            if (stringNode != null)
                                            {
                                                cellValue = stringNode.InnerText;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return cellValue;
            }

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

c# | OpenXml

How to get sheet name(s) from OpenXml document (Excel 2007)

by admin 17. June 2008 14:28

Below you'll find code snippet for reading Excel Sheet names from Office 2007 Excel document

public static List<string> GetSheetInfo(string fileName)
        {
            //  Fill this collection with a list of all the sheets.
            List<string> sheets = new List<string>();

            using (Microsoft.Office.DocumentFormat.OpenXml.Packaging.SpreadsheetDocument xlPackage = Microsoft.Office.DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(fileName, false))
            {
                Microsoft.Office.DocumentFormat.OpenXml.Packaging.WorkbookPart workbook = xlPackage.WorkbookPart;
                System.IO.Stream workbookstr = workbook.GetStream();
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(workbookstr);

                System.Xml.XmlNamespaceManager nsManager = new System.Xml.XmlNamespaceManager(doc.NameTable);
                nsManager.AddNamespace("default", doc.DocumentElement.NamespaceURI);
                System.Xml.XmlNodeList nodelist = doc.SelectNodes("//default:sheets/default:sheet", nsManager);

                foreach (System.Xml.XmlNode node in nodelist)
                {
                    string sheetName = string.Empty;
                    sheetName = node.Attributes["name"].Value;
                    sheets.Add(sheetName);
                }
            }
            return sheets;
        }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

c# | OpenXml

This page contains both secure and unsecure items

by admin 9. June 2008 15:44

Are your SSL pages plagued by the IE warning "This page contains both secure and nonsecure items. Do you want to display the nonsecure items?"

Rather than changing all the links to https://, change them to just //

<img src="//www.domain.com/image.gif" alt="" />

Alternatively, if the images or scripts are located on the same domain, you can access them relatively, rather than absolutely:

<img src="image.gif" alt="" />

Using this method, the browser will know that it must load the image securely if the web page is being loaded securely but it will also load the image normally if the page is not being accessed securely. The image will still need to be available on the other server securely.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

asp.net | html | Security | SSL

An attempt was made to access a socket in a way forbidden by its access permissions

by admin 5. June 2008 14:25

When I'm trying to access network socket on Vista it's throwing this exception:

An attempt was made to access a socket in a way forbidden by its access permissions

The only workaround I found so far is to run application as Administrator. The code to reproduce it goes like this:

System.Net.Sockets.Socket socket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.Icmp);

Anyone knows the answer for this problem?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

c# | Vista

List of assemblies marked with AllowPartiallyTrustedCallersAttribute in .net 3.5

by admin 30. May 2008 15:37
  • Accessibility.dll

  • IEExecRemote.dll

  • Microsoft.JScript.dll (applied in version 2.0)

  • Microsoft.VisualBasic.dll

  • Mscorlib.dll

  • System.dll

  • System.Configuration.dll (applied in version 2.0)

  • System.Data.dll

  • System.Data.Linq.dll

  • System.Deployment.dll (applied in version 2.0)

  • System.DirectoryServices.dll (applied in version 2.0)

  • System.DirectoryServices.Protocols.dll (applied in version 2.0)

  • System.Drawing.dll

  • System.Linq.dll

  • System.Security.dll (applied in version 2.0)

  • System.Transactions.dll (applied in version 2.0)

  • System.Web.dll (applied in versions 1.1 and 2.0)

  • System.Web.Mobile.dll (applied in versions 1.1 and 2.0)

  • System.Web.RegularExpressions.dll (applied in versions 1.1 and 2.0)

  • System.Web.Services.dll

  • System.Windows.Forms.dll

  • System.XML.dll

  • Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    asp.net

    SQL Server 2005 on Windows Server 2008 Web Edition

    by admin 29. May 2008 11:42

    When you try to install Microsoft SQL Server 2005 on a Windows Web Server 2008-based system, the installation is not completed successfully. Additionally, you receive the following warning message:

    SQL Server Edition Operating System Compatibility (Warning) Messages

    "SQL Server Edition Operating System Compatibility Some components of this edition of SQL Server are not supported on this operating system. For details, see 'Hardware and Software Requirements for Installing SQL Server 2005' in Microsoft SQL Server Books Online. "

    To resolve this problem, download and install the appropriate hotfix:

    Windows 2008 32-bit edition

    Windows 2008 64-bit edition

    Then everything seems to install ok.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    SQL 2005 | Windows 2008

    Global assembly cache Tip

    by admin 16. May 2008 10:54

    The %SystemRoot%\Assembly folder is the global assembly cache.

    You cannot directly use Windows Explorer to edit ACLs for this folder. Instead, use a command prompt and run the following command:

    cacls %windir%\assembly /e /t /p domain\useraccount:r

    Alternatively, prior to using Windows Explorer, unregister Shfusion.dll with the following command to give permissions via the GUI:

    C:\WINDOWS\Microsoft.NET\Framework\VersionNumber>regsvr32–u shfusion.dll

    After setting permissions with Windows Explorer, re-register Shfusion.dll with the following command:

    C:\WINDOWS\Microsoft.NET\Framework\VersionNumber>regsvr32 shfusion.dll

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    asp.net | IIS

    Cannot start service W3SVC on computer '.'. on IIS7

    by admin 8. May 2008 11:46

    I had a message "Cannot start service W3SVC on computer '.'." when trying to start IIS service from IIS Manager running on Windows Vista Business.

    I needed to start this IIS service manually from command line ("Run as Administrator") using this command:

    net start w3svc

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    Vista | IIS7

    How to change the Vista shutdown default “Sleep” option to “Shut Down”

    by admin 29. April 2008 23:23

    In Control Panel look for the “System and Maintenance” group.  Select “Power Options.” In the list of “Preferred plans,” click on the “Change plan settings” link.

    In the “Change Plan Settings” dialog box which appears, click on the “Change advanced power settings” link.

    In the dialog box which appears, expand the “Power buttons and lid” branch, and then expand the “Start menu power button” and in the drop-down list of options that appears, select “Shut down.”

    Click on the [Apply] button, then click on the [OK] button. Close the remaining windows to exit the control panel applet.

    Now next time you select Shutdown in the Start menu, the default action for the Sutdown dialog box will actually be Shutdown.

    I'll take some screen shots when got a little more time.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    Vista

    Requested registry access is not allowed.

    by admin 18. April 2008 11:04

    SYMPTOMS
    When you use ASP.NET to create a new event source in the event log, you may receive the following error message:

     System.Security.SecurityException: Requested registry access is not allowed.

    RESOLUTION

    Follow this link for resolution.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    asp.net | Links

    How to verify that string is in valid e-mail format

    by admin 16. April 2008 22:35

    The following code uses the static Regex.IsMatch method to verify that a string is in valid e-mail format.

    The IsValidEmail method returns true if the string contains a valid e-mail address and false if it does not, but takes no other action.

    You can use IsValidEmail to filter out e-mail addresses containing invalid characters before your application stores the addresses in a database or displays them in an ASP.NET page.

    bool IsValidEmail(string email)
    {

         return System.Text.RegularExpressions.Regex.IsMatch(email, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
    }

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    asp.net | c# | Regex

    Invoking server side code using AJAX and .ashx handlers for Virtual Earth

    by admin 14. April 2008 13:24

    Nice article about Ajax, Virtual Earth and Windows Live.

    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Tags:

    asp.net | Links | Windows Live | AJAX.net

    Powered by BlogEngine.NET 1.4.5.0
    Theme by Mads Kristensen

    Calendar

    <<  July 2009  >>
    MoTuWeThFrSaSu
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    View posts in large calendar