Using Recordsets ASP / VBScript

by Nathan 29. March 2009 08:45

 

If you receive this error 

ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

you will need to check the state of the recordset as in the code below before you access any properties of the object

 


if not oRs.state <> 1 then

        if not oRs.eof then

              if oRs("Value").Value > 0 then
                 myval = oRs("Value").Value
            else
           myval = 0     
            end if
        end if
    else
        Response.Write "Cannot find any records"
    end if
   

Tags: ,

ASP

Unable to cast object of type 'System.Web.Configuration.ScriptingAuthenticationServiceSection' to type 'System.Web.Configuration.ScriptingAuthenticationServiceSection'.

by Nathan 29. March 2009 08:42

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The entry 'ScriptModule' has already been added.

Source Error:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>


This happens when the config for a virtual directory is already defined in the root web application

There are two ways you can fix this:

<remove name="ScriptModule" />

Alternatively you can stop the  the web.config inheritance to the the virtual directory.
by adding this to the parent web.config

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>

 

I found out that the root application had .NET 3.5 references in the web.config

I tried to remove this using:

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>


the problem actually occured due to the  3.5 reference in the <configSections>

Tags:

ASP.NET

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

by Nathan 29. March 2009 08:29

I have come across this error when using a Indentity In a stored procedure.

In a stored procedure you need to define the scope indentity in a variable before you can use it in a select statement

So instead of

SELECT * FROM table WHERE id = SCOPE_IDENTITY()

You need to use 

 

SET @var = SCOPE_IDENTITY();

SELECT * FROM table WHERE id = @var

 

 @@IDENTITY  will return the last indentity across the whole database whilst SCOPE_IDENTITY() will return only the indentity related to the scope of the operation

Tags:

SQL

PHP Test Configuration Page

by Nathan 22. February 2009 11:56

To test if PHP is setup correctly on your web server, or to check your PHP Configuration.

You just need to add the below code to your a .php file:

<?php phpinfo(); ?>

Tags:

PHP

Windows XP Vista stuck in safe mode

by Nathan 17. February 2009 17:25

When you computer is stuck in safe mode everytime you reboot, even if you check run normal configuration.

There is a little System Configuration Utility in windows you can use to turn this off. 

If you go to Start -> Run

then type msconfig

then press OK

  You will need to make sure you have Normal Startup Selected.

     

Tags: ,

Windows

Inheritance issues in web.config

by Nathan 17. February 2009 17:14

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The entry 'ScriptModule' has already been added.

Source Error:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>


This happens when the config for a virtual directory is already defined in the root web application


There are two ways you can fix this:

<remove name="ScriptModule" />

Alternatively you can stop the  the web.config inheritance to the the virtual directory.
by adding this to the parent web.config

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>


--------------------------

I also came upon this problem when trying to fix this issue:

Unable to cast object of type 'System.Web.Configuration.ScriptingAuthenticationServiceSection' to type 'System.Web.Configuration.ScriptingAuthenticationServiceSection'.

which led me to realise there were .NET 3.5 references in the parent application's web.config

I tried to remove this using:

    <location path="." inheritInChildApplications="false">
    <system.web>
    ...
    </system.web>
    </location>

the problem actually occured due to the 3.5 reference in the <configSections>

Tags:

ASP.NET

ASP Connection Strings

by Nathan 9. February 2009 14:26

This is an example of a connection string for ASP (JScript and VBScript)

var connString = "Provider=sqloledb; Network Library=DBMSSOCN; Data Source=10.1.1.1;User ID=exampleUser; Password=examplePassword;Connection Timeout=90;Application Name=MyApplication;"

 

I came across the following errors in my ASP Code when my connection string was not setup correctly.

 

Microsoft OLE DB Provider for SQL Server error '80040e4d'

Invalid authorization specification

The problem was my original connection string did not have the userid and password credentials

 

Invalid connection string attribute

Invalid Data in either Password and/or Username or Initial Catalog etc

Tags: , , ,

ASP

Get Column Names for Table in MSSQL

by Nathan 3. February 2009 17:26

To get the column names of a table in MSSQL 

SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'TableName'

This is basically the MSSQL equivalent for The MySQL Command DESCRIBE TableName which displays the table details

 

I often use this so i can copy and paste into another query etc.

SELECT Column_Name + ',' FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'TableName'

then i have the commas for use in any INSERT or SELECT etc Smile

 

Tags:

SQL

Accessing Web Services in Flash AS2

by Nathan 22. January 2009 14:56

 

Here is some example code to access web services in Action Script 2

// Import the Service Library

import mx.services.*;

// define your web service URL, remember to have WDSL at the end

var webService= "http://www.mywebhost.com/webservice/service.asmx?WDSL";

var webService = new mx.services.WebService(webService);
var serviceStatus = true;
webService.onLoad = function (result)
{
    trace("Accessing Web Service: " + company.WebService);
}
;

 

 // to access a method in the web service

 function loadWebMethod() {

    var value1:String = 'test value';

    var value2:Number = 100;

    // set object to use web method called 'MyWebMethod'

    serviceObj = webService.MyWebMethod(value1,value2);

    serviceObj .onStatus = function(status) {
        trace(status);
    };

    serviceObj .onResult = function(result) {
        // Load Current Server Time
        trace(result.toString());
        var xml:XML = new XML();
        xml.ignoreWhite = true;
        xml.parseXML(result.toString());
        ServerTime.Year = xml.firstChild.attributes.year;
    };

    serviceObj .onFault = function(fault) {
        trace("Failed to Load WebService"+fault.faultCode+","+fault.faultstring);
    };
}

 

 

Tags: , , ,

Flash

Alternative to using SQL Cursors

by Nathan 13. January 2009 13:09

 

USING A CUSROR

DECLARE @FirstName varchar(255), @LastName varchar(255)

DECLARE user_cursor CURSOR FOR

SELECT FirstName,LastName FROM Users

OPEN user_cursor

FETCH NEXT FROM user_cursor

INTO  @FirstName, @LastName

WHILE @@FETCH_STATUS = 0

BEGIN

print @FirstName

FETCH NEXT FROM user_cursor INTO  @FirstName, @LastName

END

CLOSE user_cursor

DEALLOCATE user_cursor

 

 

USING A TEMPORARY TABLE/VARIABLE

SET NOCOUNT ON
DECLARE @Users TABLE (
 RowID int IDENTITY(1, 1),
 FirstName varchar(255),
 LastName varchar(255)
)

DECLARE @NumberOfRecords int, @RowCount int
DECLARE @FirstName varchar(255)

INSERT INTO @Users(FirstName,LastName)
SELECT FirstName,LastName FROM Users

SET @NumberOfRecords = @@ROWCOUNT
SET @RowCount = 1


WHILE @RowCount <= @NumberOfRecords
BEGIN        
  -- Do Operations
SET @RowCount = @RowCount + 1
END

 

Tags:

SQL

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen