Search

Wednesday, August 11, 2010

Linq:- LeftOuterJoin

from t in Table0
join t0 in Table1 on t.Id equals t0.EventAttendeeId into t0_join
from t0 in t0_join.DefaultIfEmpty()
join t1 in Table2 on t.AttendeeId equals t1.Id into t1_join
from t1 in t1_join.DefaultIfEmpty()
join t2 in Table3 on t.AttendeeCompanyId equals t2.Id into t2_join
from t2 in t2_join.DefaultIfEmpty()
select new
{


Comments=t0.Comments


}

Linq:- LeftOuterJoin_Count_GroupBy

from dept in Table1
join employee in Table2
on dept.Id equals employee.RoomTypeId

group new{dept,employee} by new
{
dept.Name,
dept.Limit,

employee.RoomTypeId

} into g
where g.Count() > 0
select new
{

d=g.Count(),
g.Key.Name,
g.Key.Limit,

}

Tuesday, March 2, 2010

To dynamically change the text at runtime in Crystal Report

To dynamically change the text at run time you will need to change the value of the TextObject programmatically. All report objects are accessed through the ReportDocument.ReportDefinition.ReportObjects collection.

1. Right-click Form1.cs in the Solution Explorer and select View Code
2. In the Form1 class, add the following code:

ReportDocument rd = new ReportDocument();

rd.Load(@"C:\\CrystalReport1.rpt");

((CrystalDecisions.CrystalReports.Engine.TextObject)rd.ReportDefinition.ReportObjects["text1"]).Text = "Italy Wins!!";

crystalReportViewer1.ReportSource = rd;

Sunday, January 31, 2010

Char Index Replace LastWord with New Word in sql

select email, SUBSTRING(email, CHARINDEX('@',email)+1,30) from details where len(email) > 0

--Replace all email domain name with new domain name

--ex:-@abc.com replace by @def.com

UPDATE details

SET Email=REPLACE(Email,SUBSTRING(email, CHARINDEX('@',email)+1,30),'def.com') where len(email) > 0

To Replace All Accurence in all Database (Find Replace From All Database)

--To replace all occurences of 'Accenture' with 'Yahoo':
EXEC SearchAndReplace 'Accenture', 'Yahoo'
GO



CREATE PROC SearchAndReplace
(
@SearchStr nvarchar(100),
@ReplaceStr nvarchar(100)
)
AS
BEGIN


SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110), @SQL nvarchar(4000), @RCTR int
SET @TableName = ''
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
SET @RCTR = 0

WHILE @TableName IS NOT NULL
BEGIN
SET @ColumnName = ''
SET @TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)

WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
BEGIN
SET @ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)
AND TABLE_NAME = PARSENAME(@TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @ColumnName
)

IF @ColumnName IS NOT NULL
BEGIN
SET @SQL= 'UPDATE ' + @TableName +
' SET ' + @ColumnName
+ ' = REPLACE(' + @ColumnName + ', '
+ QUOTENAME(@SearchStr, '''') + ', ' + QUOTENAME(@ReplaceStr, '''') +
') WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
EXEC (@SQL)
SET @RCTR = @RCTR + @@ROWCOUNT
END
END
END

SELECT 'Replaced ' + CAST(@RCTR AS varchar) + ' occurence(s)' AS 'Outcome'
END

Search text from all stored Procedure in One Database

The following stored procedure will list all stored procedure names whose text contains the parameter search string.


CREATE PROCEDURE Find_Text_In_SP
@StringToSearch varchar(100)
AS
SET @StringToSearch = '%' +@StringToSearch + '%'
SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @stringtosearch
ORDER BY SO.Name
GO

--exec Find_Text_In_SP 'vWgetuser'
--find view name from all stored procedure in database

Friday, January 22, 2010

how to get the value of a javascript pop up confirmation box in the middle of some code. - ASP.NET Forums

how to get the value of a javascript pop up confirmation box in the middle of some code.


Untitled Page






Input "abc" in the TextBox is valid




Style="position: static; display: none" Text="Button" />





****************//code behind file
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("Process OK");
}

protected void Button1_Click(object sender, EventArgs e)
{
if (!TextBox1.Text.Equals("abc"))
{
String csname = "PopupScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, csname))
{
String cstext = "confirmProcess()";
cs.RegisterStartupScript(cstype, csname, cstext, true);
}
}
else
{
Response.Write("Process OK");
}
}

Blog Archive

Contributors