Monday, 30 July 2012

How To save common windows application setting locally for all users.

To save use config file. & create config file in programdata folder which common accessible for all user.
because of virtualization concept of win 7, normal standard user can not write that file.
so i have found one solution is
Assign everyone rights to that folder which is placed in programdata folder.
so any user can access & write that file.
to do this use below code.
 DirectoryInfo dInfo = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Procharge");  
 DirectorySecurity dSecurity = dInfo.GetAccessControl();  
 dSecurity.AddAccessRule(new FileSystemAccessRule("everyone",FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit,PropagationFlags.InheritOnly,AccessControlType.Allow));  
 dInfo.SetAccessControl(dSecurity);  

Auto increment integer primary key data Transfer from one server to another

When i transferred data from one server to another i learned new thing.
we used integer primary key with auto increment in our database, instead of this if we would used guid, no need to take care of anything.

you can not transfer auto increment value because if transfer that value your primary key value changed in new database but doesn't change in your connected table.
so i found a new keyword out in mssql, we can use this keyword to used values stored in magic table means 'INSERTED','DELETED'


 update #customerOld set MerchantID = @NMerchantID  
 create table #customerPK (myNewPK INT,OldPK int,id int identity(1,1))  
 Insert into sai2.dbo.Customer  
 output INSERTED.CustomerID,0 INTO #customerPK   
 select MID,LoginID,Password,Pin,Email   
 from #customerOld As T  
 update #customerPK set OldPK = A.CustomerID from #customerPK AS T  
 inner join #customerOld AS A on A.ID = T.id  

Thursday, 26 July 2012

DataTable already belongs to another DataSet error.

DataTable already belongs to another DataSet error.
and
This row already belongs to another table


both error are same because in both case you can not assign or add your row or table to another datatable or dataset.
because it already belongs to another.
so solution is use importrow method to add row in datatable.
or
use copy method to add datatble in dataset
 mytable.ImportRow(dr);   
or
 DataTable copyDataTable;  
   copyDataTable = myDataTable.Copy();  

Wednesday, 18 July 2012

IIS issue- ISAPI and CGI Restriction list settings on the Web server


The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server


this issue would be come when u upgrade your .net framework.
to resolve this issue 
go to “ISAPI and CGI Restrictions” after click on server name & allow your new version framework.

Registry key has subkeys and recursive removes are not supported by this method


In Windows 7& vista os added extra security, so standard user can not access program files and registry without permission,
I got a error while deleting registry "Registry key has subkeys and recursive removes are not supported by this method."
here method used to delete registry is DeleteSubKey of registry.


so i understand new concept which added in win7 & vista - virtualization, 
virtualization is new thing added by win7 for extra security for malware & other viruses infection.
means when standard user create key in particular path example i called a function to create key in registry


Dim rgKey As RegistryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\sai")
means that registry create in HKEY_LOCAL_MACHINE\SOFTWARE\sai
But
it automatically create in HKEY_USERS\new classid \..\SOFTWARE\sai
means it created in profile section of that standard user.
But
if you create by admin it will create in same path which you specify.


so last point is
you can not delete registry created by admin
you can not delete standard user registry by admin bcz you dont know exact path of registry.

Monday, 16 July 2012

You can't access different domain iframe contents in your code with simple jquery code


If you want to access iframe contents you can jquery code- to see example click this
But

You can't access different domain iframe contents in your code with simple jquery code.
there some solution on google pls check below

http://ternarylabs.com/2011/03/27/secure-cross-domain-iframe-communication/

Saturday, 14 July 2012

Pass datatable through webservice

The DataTableDataRowDataView, and DataViewManager objects cannot be serialized and cannot be returned from an XML Web service. To return less than a complete DataSet, you must copy the data that you want to return to a newDataSet.


But we can pass datatable through webservice just set "name" property of datatable. After setting name it serialised.