August 2008 - Posts
I was trying to restore one database backup; which I successfully did (I'm using SQL Server 2005), and want to delete the users of the database which are restored along with the DB; I received this error which says "The database principal owns a schema in the database, and cannot be dropped".
While I googled the error, I found that the user which i want to delete is called "Database Principal" is having "DB_Owner" Role selected. That means the Database Pricipal I want to delete owns the Schema. One solution was to delete the Schema and then delete the user, :-) which I am obviously not going to do. Another Solution was to change the DB_Owner to some another "Database Principal"; let say to "dbo". I did it accordingly and then I was able to delete the user/Database Pricipal successfully.
To change the DB_Owner to some another "Database Principal"; simply Drill Down to your Database in Sql Server Management Studio and further more Drill Down to your_DB_Name > Schemas > db_owner > right click > select properties. You would find the name of the "Database Principal" that you want to delete. Change this to some another "Database Principal"; for Example, to "dbo".
You need to make the same changes to all the schemas where the "Database Principal" is having/owning the role. For Example, if it is having "db_owner, db_datareader, db_datawriter" roles; then you have to make the above said changes for all these 3 schemas.
You would find more details about this error and its solution at this page > Error Solution: Fix for 'The database principal owns a schema in the database, and cannot be dropped' Error in SQL Server 2005
I was having a requirement with my on-going project, in which I need to display the Blog RSS on Home Page. I used BlogEngine.NET
with some visual modification.
Now, on home page I need to display latest 4 entries of entered Blogs which I easily get thru RSS link from BlogEngine.NET.
But, the issue comes when I need to render the contents; that is latest 4 Blog entrties. They are entered using FCKEditor tool, So, I was getting text with HTML tags.
Because of BlogEngine.NET uses FCKEditor while posting a new Blog Entry, there are useless <p>, <div>, <Span>, <font> and tags and values and fonts with different size and colors comes with the Blog Post entry. Specially, when people directly copy and paste some contents from another web source.
I need to Strip out these HTML tags and display Plain Text for a consistant look out on my home page, so these additional <p>, <div>, <Span>, <font> and tags would not blot on my home page. To display RSS entries, means simply create a RSS Feed Reader (I think I will blog on that also), I used XSLT file to format the RSS content.
I found below function in XSLT which will remove HTML tags from my Description Field from DB (which is filled from FCKEditor):
Below is the function to remove HTML tags:
<xsl:template name="removeHtmlTags">
<xsl:param name="html"/>
<xsl:choose>
<xsl:when test="contains($html, '<')">
<xsl:value-of select="substring-before($html, '<')"/>
<!-- Recurse through HTML -->
<xsl:call-template name="removeHtmlTags">
<xsl:with-param name="html" select="substring-after($html, '>')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$html"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
You can see that the function name is removeHtmlTags which accepts one argument / parameter named as html which is my Description field that contains HTML Tags.
Logic is simple, its a recursive function which finds for '<' that is '<' means starting of any HTML Tag and take out the substring after this '<' Tag using substring-before() function as substring-before($html, '<') and again call the function with the rest of the string left after '>' that is '>' Tag.
This is how this function will be called:
<xsl:template name="RssCell">
<xsl:variable name="pureText">
<xsl:call-template name="removeHtmlTags">
<xsl:with-param name="html" select="DescriptionField" />
</xsl:call-template>
</xsl:variable>
<div height='40' class='blog_text'>
<xsl:value-of disable-output-escaping="yes" select="substring($pureText, 0, 175)"/>
</div>
</xsl:template>
One Variable is declared as pureText. removeHtmlTags() function will strip out the HTML Tags and return the Plain Text values in this pureText variable.
I am passsin DescriptionField that is my DB Field with HTML Tags.
Finally, I am displaying max 175 chars of Plain Text as substring($pureText, 0, 175) inside a DIV.
Thats It!
While I was trying to strip out all space from user input using JavaScript, First I tried with using simple replace function like var strDest = strSrc.replace(" ",""). But, I see the result that it only replaces the first occurance of the space in source string. Intrestingly, I googled and found one solution to remove all the spaces from a string that is " / /gi" parameter. Here is the JavaScript to strip out spaces from a string/user input:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function CheckSpace()
{
var strSrc = document.getElementById('<%=TextBox1.ClientID%>').value;
//here we need to give the string/char that we need to replace from source string
//in my case it is space for I gave a space between two forward slashes as var spaceFix = / /gi;
//if you want to replace for example all "a" then it should be written as var spaceFix = /a/gi;
var spaceFix = / /gi;
var strDest = strSrc.replace(spaceFix,"");
alert(strDest);
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return CheckSpace();" /></div>
</form>
</body>
</html>
Check out some of Cool Features of Apple iPhone which is expected tobe released in India around August-September by AitTel / VodaPhone.

1. no copy paste of contents (e.g. email/ SMS text) or files from one location to another (how can one NOT have this??)
2. no bluetooth transfer of anything i.e. mp3, images, videos
3. can’t use iphone as wireless modem for your PC.. hence you can’t share your internet with your own PC..
4. the camera is a simple 2 MP and can’t record video
5. no Java support (thereby a lot of existing apps won’t work)
6. the battery is locked inside the phone.. changing the same means getting to the apple store…
7. Can’t send MMS.. imagine this!!
8. no FM radio
9. can’t use MP3 files as ringtones..
10. can’t use ipod as external storage device to carry documents, pictures etc.
11. there are no expansion slots available apart from built in memory..
12. no flash or silverlight support
13. no office apps installed… i.e. u can’t read documents on iphone or quickly revise your presentation
14. if you are a coporate customer you don’t any security features like remote wipe if ur phone gets stolen or any corporate management server to manage mobile devices..
Many web pages feature images that can be maximized and restored within the same page. There is a simple way to display an image on your web page with maximization and restoration capabilities. I have taken a test image and set the initial height and width. On Click of this image I am calling MaximizeRestore() Script which will simply set the height and width based on restored boolean Flag value. Check out complete JavaScript example below:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.image {width:187px; height:224px; border: 1px solid #000000}
</style>
<script type="text/javascript">
var restored = true
function MaximizeRestore()
{
if (restored == true)
{
document.getElementById("testimage").style.width="374";
document.getElementById("testimage").style.height="448";
restored = false;
}
else
{
document.getElementById("testimage").style.width="187";
document.getElementById("testimage").style.height="224";
restored = true;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img id="testimage" src="images/image.jpg" alt="testimage" class="image" onclick="MaximizeRestore()" />
</div>
</form>
</body>
</html>
There is a nice offer from Microsoft Learning centre. Download the entire contents in PDF format of the print books for the following subjects:
Introducing Microsoft Linq,
Introducing Microsoft ASP.NET AJAX,
Introducing Microsoft Silverlight 1.0.
Here is the link > Microsoft Press - Visual Studio 2008 Free E-Book Offer