Thursday, July 24, 2008

The following module was built either with optimization....

1.
Make sure you are not trying to debug your app in "Release" mode. Verify thru configuration manager and swith to "debug"

2. Remove the dll reference in the bin folder and re-add it.
If you get an errory saying "the reference already exists", remove the .dll from the solution, add the .dll you just removed, and add the refernece in the bin folder.
After converting VS05 solution to VS08, "Error 83 Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified. C:\Users\...\Documents\Visual Studio 2008\DotNetApps\DGS VS08\web.config 107 "

The VS05 version of crystal reports is not the same as the VS08. The copied web.config file may be pointing to the previous CR version and will cause an error. Replace with the following:

--add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
--add assembly="CrystalDecisions.Enterprise.Framework, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
--add assembly="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
--add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
--add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
--add assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
--add assembly="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"




When trying to add dll's that were created in Visual Studio 2005 to a Visual Studio 2008 solution, you get an error that "Project file is not writable: C:\Users\..."

Use explorer to turn "read only" off for the project folder, and try again.
"Network User" appears as the login type after logging into a applicaion (instead of the actual user's login name).

The problem:

In the web.config file, set "identity impersonate="false"" to "true".

Sunday, July 20, 2008

Stored Procedure to search for a particular string within an entire database.

IF OBJECT_ID('GetTbColvalues') IS NOT NULL DROP PROC GetTbColvalues
GO

CREATE PROCEDURE GetTbColvalues (
@txtvalue varchar(128) = null
)
AS
DECLARE
@execstr varchar(1000),
@objectname sysname,
@colname sysname

SET NOCOUNT ON
IF @txtvalue IS NULL
BEGIN
RAISERROR ('You must specify the value to search', 16, 1)
RETURN
END

DECLARE tb_fetch_cursor CURSOR FOR
SELECT name FROM sysobjects WHERE type = 'U'
OPEN tb_fetch_cursor
FETCH NEXT FROM tb_fetch_cursor INTO @objectname
WHILE (@@fetch_status <> -1)
BEGIN
DECLARE col_fetch_cursor CURSOR FOR
SELECT name FROM syscolumns WHERE id = OBJECT_ID(@objectname) AND type IN
(SELECT type FROM systypes WHERE name = 'char' OR name = 'nchar' OR name = 'varchar'
OR name = 'nvarchar' OR name = 'text' OR name = 'ntext')
OPEN col_fetch_cursor
FETCH NEXT FROM col_fetch_cursor INTO @colname
WHILE (@@fetch_status <> -1)
BEGIN
SELECT @execstr = 'IF EXISTS (SELECT * FROM ' + @objectname + ' WHERE ' + @colname + ' like ''%' + @txtvalue + '%'') BEGIN SELECT ''' + @objectname + ''' as tbname, ''' + @colname + ''' as colname PRINT '''' END'
EXEC (@execstr)
FETCH NEXT FROM col_fetch_cursor INTO @colname
END
DEALLOCATE col_fetch_cursor
FETCH NEXT FROM tb_fetch_cursor INTO @objectname
END
DEALLOCATE tb_fetch_cursor
GO
SQL Server blocked access to procedure 'sys.sp_OACreate' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online.

I want to use sp_configure . Most of the help I could find revolved around the SQL Server Surface Area Configuration and using either the SQL Server 2005 Surface Area Configuration tool or even the command line sac Utility. I found that the sp_configure option is Ole Automation Procedures and so the code is:
EXEC sp_configure 'Ole Automation Procedures';
GO

but this results in the following:
Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51
The configuration option 'Ole Automation Procedures' does not exist, or it may be an advanced option.

and so needs to be paired with the Show Advanced Options setting, and so the following is required:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO

This results in the following:
Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
Configuration option 'Ole Automation Procedures' changed from 0 to 1. Run the RECONFIGURE statement to install.

and when I re-run the deployment scripts I get no errors. Hurrah!

Friday, July 11, 2008

Do not inherit from System.web.ui.page:

Using Custom BasePage Class in ASP.Net

Every Code Behind class of ASP.Net pages will inherit System.Web.UI.Page Class by default.