To dynamically load a user control in aspx page and call a public function in user control through the aspx page.
Control Guest_Comments = Page.LoadControl(Page.ResolveUrl("~/ResponseChunk.ascx"));
PHIndex.Controls.Add(Guest_Comments);
((ResponseChunk)Guest_Comments).GetRatingResponse(Convert.ToInt32(_PropertyID));
Wednesday, September 30, 2009
Friday, September 25, 2009
Trigger to insert in another table
ALTER TRIGGER onInsert ON Employee
FOR INSERT
AS
DECLARE @Age INT
DECLARE @message VARCHAR(50)
SET @Age=(SELECT age FROM inserted)
IF(@Age>20 and @Age<50)
BEGIN
INSERT INTO Employee1([Name],Age)
SELECT [Name],Age FROM inserted i
END
ELSE
BEGIN
SELECT @message 'message'
END
FOR INSERT
AS
DECLARE @Age INT
DECLARE @message VARCHAR(50)
SET @Age=(SELECT age FROM inserted)
IF(@Age>20 and @Age<50)
BEGIN
INSERT INTO Employee1([Name],Age)
SELECT [Name],Age FROM inserted i
END
ELSE
BEGIN
SELECT @message 'message'
END
Creating a Microsoft installer Package(MSI)
Creating a Microsoft installer Package(MSI)
Use Visual Studio 2005 to create a base Windows Installer package
To create a base Windows Installer package, follow these steps:
1. Start Visual Studio 2005.
2. On the File menu, click New, and then click Project.
3. In the New Project dialog box, expand Other Project Types under Project Types, click Setup and Deployment, and then click Setup Project under Visual Studio installed templates.
4. In the Name box, type Caspol.msi.
5. In the Location box, type the location of the Caspol.msi file, and then click OK.
6.A page with 2 panes open.
in the left pane under "filesystem on target machine" select application folder and remove rest other folder
7. in the solution explorer right click the newly created setup project and click Add--->ProjectOutput.add project output group box opens
8. choose primary output and contenet files from add project output group box and then ok.
9.select the setup project from solution explorer and and press f4..to view and edit the property
10.right click on root solution in solution explorer and go to properties,a solution property pages window opens.in the window, uncheck the "build" checkbox for the setup project.and then build the solution..
Here are some detailed instuctions on how to setup your web deployment project. There is a plugin below you may or may not need.
VS2005 / VS2008
http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx
http://www.dotnetheaven.com/Uploadfile/vijendrapal/DeployingASPNETAppls10292005000351AM/DeployingASPNETAppls.aspx?ArticleID=d7f3111a-d8d3-49ff-8ae6-04a24a2eae3a
http://msdn.microsoft.com/en-us/library/ms242499(VS.80).aspx
Use Visual Studio 2005 to create a base Windows Installer package
To create a base Windows Installer package, follow these steps:
1. Start Visual Studio 2005.
2. On the File menu, click New, and then click Project.
3. In the New Project dialog box, expand Other Project Types under Project Types, click Setup and Deployment, and then click Setup Project under Visual Studio installed templates.
4. In the Name box, type Caspol.msi.
5. In the Location box, type the location of the Caspol.msi file, and then click OK.
6.A page with 2 panes open.
in the left pane under "filesystem on target machine" select application folder and remove rest other folder
7. in the solution explorer right click the newly created setup project and click Add--->ProjectOutput.add project output group box opens
8. choose primary output and contenet files from add project output group box and then ok.
9.select the setup project from solution explorer and and press f4..to view and edit the property
10.right click on root solution in solution explorer and go to properties,a solution property pages window opens.in the window, uncheck the "build" checkbox for the setup project.and then build the solution..
Here are some detailed instuctions on how to setup your web deployment project. There is a plugin below you may or may not need.
VS2005 / VS2008
http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx
http://www.dotnetheaven.com/Uploadfile/vijendrapal/DeployingASPNETAppls10292005000351AM/DeployingASPNETAppls.aspx?ArticleID=d7f3111a-d8d3-49ff-8ae6-04a24a2eae3a
http://msdn.microsoft.com/en-us/library/ms242499(VS.80).aspx
Thursday, September 17, 2009
TARGET = "_blank"
TARGET = "_blank"
"_blank" opens the link in a new window.
Sample Code
===========
<html>
<head>
<title>
page</title>
</head>
<body>
<a href="http://www.google.co.in/" target="_blank">Google</a>
</body>
</html>
"_blank" opens the link in a new window.
Sample Code
===========
<html>
<head>
<title>
page</title>
</head>
<body>
<a href="http://www.google.co.in/" target="_blank">Google</a>
</body>
</html>
Wednesday, September 16, 2009
Sql-CEILING and Floor
CEILING
Returns the smallest integer that is greater than, or equal to, the given numeric expression.
for instance,
SELECT ceiling(1.5) will return "2"
--------------------------------------------------------------------------------
FLOOR
Returns the largest integer less than or equal to the given numeric expression
for instance SELECT floor(1.5)
will return "1"
Returns the smallest integer that is greater than, or equal to, the given numeric expression.
for instance,
SELECT ceiling(1.5) will return "2"
--------------------------------------------------------------------------------
FLOOR
Returns the largest integer less than or equal to the given numeric expression
for instance SELECT floor(1.5)
will return "1"
Tuesday, September 15, 2009
Query To get all the tables in Database
SELECT *
FROM sys.objects
WHERE type = 'u'
-------------------------------
Where 'u' stands for USER_TABLE
Where 'P' stands for SQL_STORED_PROCEDURE
Where 'TR' stands for SQL_TRIGGER
-------------------------------
FROM sys.objects
WHERE type = 'u'
-------------------------------
Where 'u' stands for USER_TABLE
Where 'P' stands for SQL_STORED_PROCEDURE
Where 'TR' stands for SQL_TRIGGER
-------------------------------
Labels:
Sq lServer
To show all the store procedures in a database
SELECT name
FROM sys.objects
WHERE type = 'P'
Following script will provide name of all the stored procedure which were created in last 7 days, they may or may not be modified after that.
-------------------------------------------------------------------------------------
SELECT *
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,create_date,GETDATE()) < 7
FROM sys.objects
WHERE type = 'P'
Following script will provide name of all the stored procedure which were created in last 7 days, they may or may not be modified after that.
-------------------------------------------------------------------------------------
SELECT *
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,create_date,GETDATE()) < 7
Labels:
Sq lServer
Specifiying connection string in Registry
go to start-->Run-->regedit Registory editor opens..
right click on Software and to add new key by name Myproject..(right click software new->key)
then go to Myproject and rightclick to add new key by name proj01(same as above)
after creating the proj01 key ..right click on the right pane to add a string value..to do that
right click on right pane new->string value
here the connection string can be specified in the string value in the "data" column and name as "ConnKey"
" server=192.110.210.34;database=MyDatabase;uid=user01;pwd=user01; "
==============================================================================================
go to web.config
in <appSettings> section write the folowing code
<appSettings>
<add key="RegistryPath" value="SOFTWARE\MyProject\Proj01"/>
</appSettings>
to get the connection string from the registry path
=====================================================
public static string GetConnectionString()
{
string ConnString = string.Empty;
RegistryKey regPath = Registry.LocalMachine.OpenSubKey(ConfigurationManager.AppSettings["RegistryPath"].ToString(), false);
try
{
if (regPath != null)
{
ConnString = regPath.GetValue("ConnKey").ToString();
}
else
{
throw new Exception("Error in establishing Connection with the DataBase");
}
}
catch (Exception e)
{
throw e;
}
return ConnString;
}
right click on Software and to add new key by name Myproject..(right click software new->key)
then go to Myproject and rightclick to add new key by name proj01(same as above)
after creating the proj01 key ..right click on the right pane to add a string value..to do that
right click on right pane new->string value
here the connection string can be specified in the string value in the "data" column and name as "ConnKey"
" server=192.110.210.34;database=MyDatabase;uid=user01;pwd=user01; "
==============================================================================================
go to web.config
in <appSettings> section write the folowing code
<appSettings>
<add key="RegistryPath" value="SOFTWARE\MyProject\Proj01"/>
</appSettings>
to get the connection string from the registry path
=====================================================
public static string GetConnectionString()
{
string ConnString = string.Empty;
RegistryKey regPath = Registry.LocalMachine.OpenSubKey(ConfigurationManager.AppSettings["RegistryPath"].ToString(), false);
try
{
if (regPath != null)
{
ConnString = regPath.GetValue("ConnKey").ToString();
}
else
{
throw new Exception("Error in establishing Connection with the DataBase");
}
}
catch (Exception e)
{
throw e;
}
return ConnString;
}
Thursday, September 10, 2009
Concatinating Multiple column value into a single column
Concatinating Multiple column value into a single column
SELECT a.ID 'PropertyID', a.Heading,RateSummary AS Description,c.propertyphotopath,pm.Photos,
pm.Visitors,pm.Inquiries,pm.PublishedDate,a.ExpiryDate
,Case pm.Photos when 0 then '' else 'Currently with'+' '+convert(varchar(50),pm.Photos)+' '+'Photos' End+','
+Case pm.Inquiries when 0 then '' else convert(varchar(50),pm.Inquiries)+' '+'Inquiries Since'+' '+convert(varchar(50),FirstEnquiryDate,106)+',' End
+Case pm.Visitors when 0 then '' else convert(varchar(50),pm.Visitors)+' '+'Visitors Since'+' '+Convert(varchar(50),FirstVisitedDate,106)+',' end
+Case DATEDIFF(day,,a.ExpiryDate) when 0 then '' else 'Expires in '+ ' '+convert(varchar(50),DATEDIFF(day, a.createdDate,a.ExpiryDate))+' '+'Days on'+' '+convert(varchar(50),a.ExpiryDate,106) end
+case isnull(pm.PublishedDate,0) when 0 then '' else ' '+'First Published on'+convert(varchar(50),pm.PublishedDate,106) end
FROM PropertyInfo a
INNER JOIN RateDetail b ON a.ID = b.PropertyInfoID
LEFT OUTER JOIN photogallery c ON a.ID = c.PropertyInfoID
Inner join propertymetrics pm on a.ID=pm.PropertyInfoID
WHERE c.ISthumbnail = 'TRUE';
SELECT a.ID 'PropertyID', a.Heading,RateSummary AS Description,c.propertyphotopath,pm.Photos,
pm.Visitors,pm.Inquiries,pm.PublishedDate,a.ExpiryDate
,Case pm.Photos when 0 then '' else 'Currently with'+' '+convert(varchar(50),pm.Photos)+' '+'Photos' End+','
+Case pm.Inquiries when 0 then '' else convert(varchar(50),pm.Inquiries)+' '+'Inquiries Since'+' '+convert(varchar(50),FirstEnquiryDate,106)+',' End
+Case pm.Visitors when 0 then '' else convert(varchar(50),pm.Visitors)+' '+'Visitors Since'+' '+Convert(varchar(50),FirstVisitedDate,106)+',' end
+Case DATEDIFF(day,,a.ExpiryDate) when 0 then '' else 'Expires in '+ ' '+convert(varchar(50),DATEDIFF(day, a.createdDate,a.ExpiryDate))+' '+'Days on'+' '+convert(varchar(50),a.ExpiryDate,106) end
+case isnull(pm.PublishedDate,0) when 0 then '' else ' '+'First Published on'+convert(varchar(50),pm.PublishedDate,106) end
FROM PropertyInfo a
INNER JOIN RateDetail b ON a.ID = b.PropertyInfoID
LEFT OUTER JOIN photogallery c ON a.ID = c.PropertyInfoID
Inner join propertymetrics pm on a.ID=pm.PropertyInfoID
WHERE c.ISthumbnail = 'TRUE';
Labels:
Sq lServer
To Bind A value from database to button and using that value to redirect in code behind file
Using OnCommand in Button
.aspx page
--------------
<asp:ImageButton ID="img01" runat="server" ImageUrl="~/Images/edit_j_btn.jpg" OnCommand="onEdit_Click" CommandArgument='<%#Eval("UserId") %>' />
code behind
--------------
public void onEdit_Click(object sender,System.Web.UI.WebControls.CommandEventArgs e)
{
int userid= Convert.ToInt32(e.CommandArgument);
Response.Redirect("Home.aspx?_UserId=" + userid);
}
.aspx page
--------------
<asp:ImageButton ID="img01" runat="server" ImageUrl="~/Images/edit_j_btn.jpg" OnCommand="onEdit_Click" CommandArgument='<%#Eval("UserId") %>' />
code behind
--------------
public void onEdit_Click(object sender,System.Web.UI.WebControls.CommandEventArgs e)
{
int userid= Convert.ToInt32(e.CommandArgument);
Response.Redirect("Home.aspx?_UserId=" + userid);
}
Subscribe to:
Posts (Atom)