Thursday, December 30, 2010

showModalDialog PostBack issues in

If we open a page using showModalDialog('popuppage.aspx') in javascript and then when we submit this page it opens a new window so , here is the way to get rid of it.
just need to add this tag in popuppage.aspx in header section of the page.
<base target="_self" />

setting parent from control value in pop up page using opener.document.getElementById(' in

I was working on a product and I got a code snipped like this in existing code :
opener.document.getElementById('ctl00_ContentPlaceHolder1_TextBox1').value = "abccd';

So I decided to remove this hardcoded thing ctl00_ContentPlaceHolder1 , and I tried like
opener.document.getElementById('<%= TextBox1.ClientID %>').value = "abccd';
but it never worked , reason was because this textBox1 is not available on popup page ,
then i got a way to do this without any hard coding and its very simple , just pass control id from parent page to popup page and then use it in pup page as :

assuming that i have a textbox named "txtName"

var txtNameClientObject = '<%= txtName.ClientID %>';'Child.aspx?txtName='+txtNameClientObject);

and then in popup page

opener.document.getElementById('<%= Request["txtName"] %>').value = 'from child';

Wednesday, December 29, 2010

Username and password when use http://localhost in firefox but works in IE.

IIS uses Integrated Authentication and by default IE has the ability to use your windows user account...and need to configure this in fire fox.

here are the steps to do:

1) Open up Firefox and type in about:config as the url

2) In the Filter Type in ntlm

3) Double click "network.automatic-ntlm-auth.trusted-uris" and type in localhost and hit enter

Biztalk Error System.String must be Xml serializable to be a message part type

I was doing some development in Biztalk 2006 with Vs 2005 . I created an orchestration and there was one message in it that has type System.String. When I tried to compile my prjoect i was getting following error

"Biztalk Error System.String must be Xml serializable to be a message part type"

I checked the System.String and it was already serializable and I was surprised why this error is occurred.

I was unable to solve the problem then at last I closed the visual studio and started it again and tried to compile my project and it was build successfully .

So the solution is : just restart the visual studio and enjoy

Tuesday, December 28, 2010

How to Select Top N records using a varaible or in a procedure to pass n

here is the way :

DECLARE @c int
SET @c = 10

SELECT TOP (@c) * FROM TableName

Getting only Date part from a data time column

here is the way:

and if you have a column of datetime type in your DB and you want to use it in where clause to get the records that matches a date and your DB has values with time also, then you need to use query like this.

SELECT * FROM TableThathasDateTimeColumn where
DATEADD(D, 0, DATEDIFF(D, 0, modifiedate)) = (SELECT convert(datetime, '2010.12.14', 102) )

this will return all recrods from TableThathasDateTimeColumn table that has modified date of December 14, 2010 , irrespective of time that presensts in modifiedate column.

Replication Error : the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission

i was having this issue while implementing replication from SQL server 2008 to sql server 2005 . the DB on sql server 2008 was restored from another sql server 2005 server.

While Synchornizing the data with publisher data i have this error .

snapsthost is corrupted or not fully generated

so I just changed the owner of both databses on publisher server and also on subscriber server using this code
USE databsename
sp_changedbowner sa -- to change DB Owner
ALTER AUTHORIZATION ON DATABASE::databsename TO sa --change the authorization schema.

How to Remove Replication from server / Cannot drop server ‘repl_distributor’ because it is used as a Distributor in replication

I was having problem to remove Replication from server after removing the replication from the db using
EXEC sp_removedbreplication 'DBName';

then after getting some research i got how to do this, here is the procedure

EXEC master.dbo.sp_serveroption @server=N'abcserver', @optname=N'dist', @optvalue=N'false'

use sp_helpserver to get servers.

or use this command
EXEC sp_dropdistributor @no_checks = 1, @ignore_distributor = 1

How to Delete "distribution" replication database

I was having a problem to delete distribution database created by replication, I was unable to remove this database even i removed all configurations related to replication.

Then after some research i got this way to delete it. First take if offline and then delete it.

DROP DATABASE distribution;

Then delete physical files .ldf and .mdf from the disk manually.