If you have a url parameters specified in your url like so:
somepage.aspx?recordId=1
And then add a anchor to it like so:
somepage.aspx?recordId=1#middleofpage
IE 6 will read recordId as 1#middleofpage instead of just 1. The way to fix this is to either add a & symbol in from of the pound like so:
somepage.aspx?recordid=1middleofpage
Or, do some regex match to remove the values from the # symbol on so that you end up with only the value you want.
If your lucky, this is your only problem. However, I also have had the problem in IE 6 and 7 where a response.redirect will remove the anchor part completely. So a url like so:
sompage.aspx?recordid=1#middleofpage
Will be somepage.aspx?recordid=1 when it redirects in IE 6/7, even though the code I used was response.redirect("somepage.aspx?recordid=1#middleofpage"). Of course this works fine in all other browsers including IE 8. This happens randomly and I have not figured out a solution. My work around was to send the request to another page and do the redirect from there because adding the # symbol to my url worked fine there, because it's a different page of course:)
Monday, January 25, 2010
Friday, December 26, 2008
SQL Loop
declare @query varchar(100),@dbname sysnamedeclare @dblist table (dbname sysname)insert into @dblist(dbname) select name from sys.databaseswhere name not in ('master', 'model', 'msdb', 'tempdb')while (select count(*) from @dblist) > 0beginselect top 1 @dbname = dbname from @dblistselect @query = 'dbcc checkdb(' + quotename(@dbname) + ')'exec(@query)delete from @dblist where dbname = @dbnameend
go
go
Tuesday, December 2, 2008
Search all fields in a table
CREATE PROCEDURE [dbo].[FindValue] @TableName NVARCHAR(128), /* Must be a valid table or view name, must not be quoted or contain a schema*/ @Value NVARCHAR(4000), /*May contain wildcards*/ @schema NVARCHAR(128) = 'dbo' /*May be left out*/ AS /* Sample Execution Exec FindValue @TableName = 'spt_monitor', @Value = '8', @schema = 'dbo' */ /* If given a string it will finds all rows where any char, varchar, or their Unicode equivalent which contain that string in the selected table or view. Note that this only works on objects which have entries in information_schema.columns, which excludes certain system objects. If given a numeric value it will check those text types for a match as well as numeric types. If given a possible date, it will also check date type. The string that is being searched for may contain wildcard characters such as %. This will NOT search text, ntext, xml, or user defined fields. This may return a row more than once if the search string is found in more than one column in that row. */ /**************************** Declare Variables ***********************/ DECLARE @columns TABLE (ColumnName NVARCHAR(128)) DECLARE @sql NVARCHAR(MAX) /************************** Populate Table Variable *****************/ /*Takes the names of string type columns for the selected table */ INSERT INTO @columns (ColumnName) SELECT Column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE Table_schema = @schema AND Table_name = @TableName AND data_type IN ('char', 'nchar', 'varchar', 'nvarchar') /* If it is numeric, also check the numeric fields */ IF ISNUMERIC(@value) = 1 INSERT INTO @columns (ColumnName) SELECT Column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE Table_schema = @schema AND Table_name = @TableName AND data_type IN ('int', 'numeric', 'bigint', 'money', 'smallint', 'smallmoney', 'tinyint', 'float', 'decimal', 'real') IF ISDATE(@value) = 1 INSERT INTO @columns (ColumnName) SELECT Column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE Table_schema = @schema AND Table_name = @TableName AND data_type IN ('datetime', 'smalldatetime') /********************* Prepare dynamic SQL Statement to Execute **********/ SELECT @sql = CASE WHEN @sql IS NULL THEN 'Select ''' + ColumnName + ''' as ContainingColumn, * From ' + QUOTENAME(@Schema) + '.' + QUOTENAME(@TableName) + ' where ' + ColumnName + ' like ''' + @Value + ''' ' WHEN @sql IS NOT NULL THEN @sql + 'UNION ALL Select ''' + ColumnName + ''' as ContainingColumn, * From ' + QUOTENAME(@Schema) + '.' + QUOTENAME(@TableName) + ' where ' + ColumnName + ' like ''' + @Value + ''' ' END FROM @columns /******************* Execute Statement and display results ***********/ --print @sql /* This may be uncommented for testing purposes */ EXEC (@sql)
Wednesday, September 17, 2008
Report server report viewer 404 - File or directory not found
With SQL Server 2008 and IIS7, you may run into this error like I did. The fix for me was to do the following:
Under IIS area, double-click on Handler Mappings icon. At the Action pane on your right, click on Add Managed Handler. At the Add Managed Handler dialog, enter the following: Request path: Reserved.ReportViewerWebControl.axd Type: Microsoft.Reporting.WebForms.HttpHandler Name: Reserved-ReportViewerWebControl-axd Click OK.
You may also need to add this to your web.config, although I think this is only for older versions of IIS:
<add name="Reserved-ReportViewerWebControl-axd"
path="Reserved.ReportViewerWebControl.axd" verb="*"
type="Microsoft.Reporting.WebForms.HttpHandler" resourceType="Unspecified"/> in
the <handlers> section.
Under IIS area, double-click on Handler Mappings icon. At the Action pane on your right, click on Add Managed Handler. At the Add Managed Handler dialog, enter the following: Request path: Reserved.ReportViewerWebControl.axd Type: Microsoft.Reporting.WebForms.HttpHandler Name: Reserved-ReportViewerWebControl-axd Click OK.
You may also need to add this to your web.config, although I think this is only for older versions of IIS:
<add name="Reserved-ReportViewerWebControl-axd"
path="Reserved.ReportViewerWebControl.axd" verb="*"
type="Microsoft.Reporting.WebForms.HttpHandler" resourceType="Unspecified"/> in
the <handlers> section.
Friday, July 18, 2008
How to pass windows authentication when serving a report with Report Viewer from Reporting Services
First create the following class:
[Serializable]
public sealed class ReportServerNetworkCredentials : IReportServerCredentials
{
#region IReportServerCredentials Members
///
/// Provides forms authentication to be used to connect to the report server.
///
/// A Report Server authentication cookie.
/// The name of the user.
/// The password of the user.
/// The authority to use when authenticating the user, such as a Microsoft Windows domain.
///
public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string userName,
out string password, out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
return false;
}
///
/// Specifies the user to impersonate when connecting to a report server.
///
///
///A WindowsIdentity object representing the user to impersonate.
public WindowsIdentity ImpersonationUser
{
get
{
return null;
}
}
///
/// Returns network credentials to be used for authentication with the report server.
///
///
///A NetworkCredentials object.
public System.Net.ICredentials NetworkCredentials
{
get
{
string userName = "username";
string domainName = "domain or computer";
string password = "password";
return new System.Net.NetworkCredential(userName, password, domainName);
}
}
#endregion
}
Then in the code behind of the page with the report viewer, do the following on page load:
protected void Page_Load(object sender, EventArgs e)
{
myReportViewer.ServerReport.ReportServerCredentials = new ReportServerNetworkCredentials();
}
Some notes about this. When working locally, I could get the report view to display without prompting me for a password (the authentication worked), but the data wouldn'd display. I'm not sure if this is a Vista issue or what, but when I publised it to the server, everything worked fine. Well, everything worked fine after I download the Microsoft Report Viewer Redistributable 2008 from mirosoft and installed it. You can download it here: http://www.microsoft.com/downloads/details.aspx?FamilyID=CC96C246-61E5-4D9E-BB5F-416D75A1B9EF&displaylang=en. This is necessary because the .net Report View control is part of VS 2008, so not included on the server.
[Serializable]
public sealed class ReportServerNetworkCredentials : IReportServerCredentials
{
#region IReportServerCredentials Members
///
/// Provides forms authentication to be used to connect to the report server.
///
/// A Report Server authentication cookie.
/// The name of the user.
/// The password of the user.
/// The authority to use when authenticating the user, such as a Microsoft Windows domain.
///
public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string userName,
out string password, out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
return false;
}
///
/// Specifies the user to impersonate when connecting to a report server.
///
///
///
public WindowsIdentity ImpersonationUser
{
get
{
return null;
}
}
///
/// Returns network credentials to be used for authentication with the report server.
///
///
///
public System.Net.ICredentials NetworkCredentials
{
get
{
string userName = "username";
string domainName = "domain or computer";
string password = "password";
return new System.Net.NetworkCredential(userName, password, domainName);
}
}
#endregion
}
Then in the code behind of the page with the report viewer, do the following on page load:
protected void Page_Load(object sender, EventArgs e)
{
myReportViewer.ServerReport.ReportServerCredentials = new ReportServerNetworkCredentials();
}
Some notes about this. When working locally, I could get the report view to display without prompting me for a password (the authentication worked), but the data wouldn'd display. I'm not sure if this is a Vista issue or what, but when I publised it to the server, everything worked fine. Well, everything worked fine after I download the Microsoft Report Viewer Redistributable 2008 from mirosoft and installed it. You can download it here: http://www.microsoft.com/downloads/details.aspx?FamilyID=CC96C246-61E5-4D9E-BB5F-416D75A1B9EF&displaylang=en. This is necessary because the .net Report View control is part of VS 2008, so not included on the server.
How to enable Asp.NET security tables for a database.
You can run Aspnet_regsql.exe without any command-line arguments to run a wizard that will walk you through specifying connection information for your SQL Server database and installing or removing the database elements for supported features. You can also run Aspnet_regsql.exe as a command-line tool to specify database elements for individual features to add or remove. To specify SQL cache dependency settings or set up session state, you must use the command-line tool.
To run the wizard, run Aspnet_regsql.exe without any command-line arguments, as shown in the following example.
C:\%windir%\Microsoft.NET\Framework\[versionNumber]\aspnet_regsql.exe
To run the wizard, run Aspnet_regsql.exe without any command-line arguments, as shown in the following example.
C:\%windir%\Microsoft.NET\Framework\[versionNumber]\aspnet_regsql.exe
Thursday, June 12, 2008
How to query a list in sharepoint
SELECT dbo.UserData.tp_ID,
dbo.UserData.tp_ListId,
dbo.UserData.tp_Author,
dbo.UserData.nvarchar1,
dbo.UserData.nvarchar2,
dbo.UserData.nvarchar3,
dbo.UserData.nvarchar4,
dbo.UserData.nvarchar5,
dbo.UserData.nvarchar6,
dbo.UserData.nvarchar7,
dbo.UserData.nvarchar8,
dbo.UserData.nvarchar9 ,
dbo.UserData.nvarchar10,
dbo.UserData.nvarchar11,
dbo.UserData.nvarchar12,
dbo.UserData.* –dont forget to modify this to snatch only the columns you need
FROM dbo.Lists
INNER JOIN
dbo.UserData ON dbo.Lists.tp_ID = dbo.UserData.tp_ListId
WHERE
(dbo.UserData.tp_ListId = ‘{B44327F5-95E9-4504-A3BF-1E6751C452D6}’)
–optional WHERE clause, this pulls data for ONE list
dbo.UserData.tp_ListId,
dbo.UserData.tp_Author,
dbo.UserData.nvarchar1,
dbo.UserData.nvarchar2,
dbo.UserData.nvarchar3,
dbo.UserData.nvarchar4,
dbo.UserData.nvarchar5,
dbo.UserData.nvarchar6,
dbo.UserData.nvarchar7,
dbo.UserData.nvarchar8,
dbo.UserData.nvarchar9 ,
dbo.UserData.nvarchar10,
dbo.UserData.nvarchar11,
dbo.UserData.nvarchar12,
dbo.UserData.* –dont forget to modify this to snatch only the columns you need
FROM dbo.Lists
INNER JOIN
dbo.UserData ON dbo.Lists.tp_ID = dbo.UserData.tp_ListId
WHERE
(dbo.UserData.tp_ListId = ‘{B44327F5-95E9-4504-A3BF-1E6751C452D6}’)
–optional WHERE clause, this pulls data for ONE list
Subscribe to:
Posts (Atom)