Tuesday, November 21, 2017

Ensure that this project has Microsoft.Bcl.Build installed and packages.config is located next to the project file


In my Xamarin form application their was dependency Restclient on
Microsoft.Bcl.Build
Microsoft.Bcl.
i just remove all using nuget and install Newtonsoft.Json

Thursday, November 9, 2017

SQL get all table column which is null in database




 create table #SuspectColumns (  
   TABLE_SCHEMA sysname,  
   TABLE_NAME sysname,  
   COLUMN_NAME sysname  
 )  
 declare csrColumns cursor fast_forward for  
   select TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME  
     from INFORMATION_SCHEMA.COLUMNS  
     where IS_NULLABLE = 'YES'  
 declare @TABLE_SCHEMA sysname,  
     @TABLE_NAME sysname,  
     @COLUMN_NAME sysname,  
     @sql nvarchar(max)   
 open csrColumns  
 while (1=1) begin  
   fetch next  
     from csrColumns  
     into @TABLE_SCHEMA, @TABLE_NAME, @COLUMN_NAME  
   if @@FETCH_STATUS<>0 break  
   set @sql = N'if not exists(select 1 from ' + QUOTENAME(@TABLE_SCHEMA) + N'.' + QUOTENAME(@TABLE_NAME) + N' where ' + QUOTENAME(@COLUMN_NAME) + N'is not null)  
            insert into #SuspectColumns values (''' + @TABLE_SCHEMA + N''',''' + @TABLE_NAME + N''',''' + @COLUMN_NAME + N''')'  
   exec sp_executesql @sql  
 end /* while */  
 close csrColumns  
 deallocate csrColumns  
 select * from #SuspectColumns  
 drop table #SuspectColumns  



This will return table name and column name which is null in database











Tuesday, November 7, 2017

sql check duplicate column values for same id


i want to check  if any customer has more than 1 same insplanid_FK.


 ;with cte as  
 (  
 SELECT *,  
 count(cusid_FK) OVER (partition by cusid_FK,ccardholdername,insplanid_FK) as V_COUNT  
 FROM cusinsplan  
 WHERE ISNULL(insplanid_FK,'')!=''  
 )  
 select * from cte where V_COUNT>1  









Thursday, August 10, 2017

How to view the SQL generated query by the Entity Framework


If we want to write log file of Entity Framework query in EF 6 we can follow this step

Step 1: Open EDMX cs file and copy the code:


  protected override void OnModelCreating(DbModelBuilder modelBuilder)  
     {  
       Database.Log = (query) => Debug.Write(query);  
     }  


Step 2 : write log on your Entity Framework query


  refauthrequests refauthEntity = EM_Refauthrequests.ConvertToEntity(vsspoAuditModel);  
       _db.refauthrequests.Add(refauthEntity);  
       _db.Database.Log = queryLog =>  
       {  
         Debug.Print(queryLog); // Debug.Print will show the output on visual studio output window You can write log using queryLog value  
       };  
       _db.SaveChanges();  


If you set debugger you will see the output window




Tuesday, July 25, 2017

SQL Generate Date from given date range



 WITH Dates AS (  
     SELECT  
      [Date] = CONVERT(DATETIME,'1-1-2017')  
     UNION ALL SELECT  
      [Date] = DATEADD(DAY, 1, [Date])  
     FROM  
      Dates  
     WHERE  
      Date < '12-31-2017'  
 ) SELECT [Date]  
 FROM Dates  
 OPTION (MAXRECURSION 1000)  



Friday, July 14, 2017

Run all SQL files from a folder



Run all SQL files from  a folder you can follow the process that will save your time for executing SQL script


Copy this code in a notepad file and change the Server, Database, Username And Password value as your self and save it as a .bat file. copy the file in your SQL script folder and run this bat file.

 REM  
  REM development environment only!!  
 REM  
 pause  
 for %%G in (*.sql) do sqlcmd /S "192.168.10.139\SQLEXPRESS" /d "VSSPORT_DEV" -U "atiour" -P "atiour" -i"%%G"  
 pause  
 REM  
  REM All Script Run Successfully  
 REM  




Monday, May 8, 2017

nopcommerce gmail and godaddy email setting

Gmail Setting

1. Login to your gmail account.
2. Visit this page https://accounts.google.com/DisplayUnlockCaptcha and click on button to allow access.
3. Visit this page https://www.google.com/settings/security/lesssecureapps and enable access for less secure apps.
4. Login to your nopCommerce admin portal and visit this page http://website_name.com/Admin/EmailAccount/List and click edit  and click to delete the account.
5. Now use following details:
   Email address: youraddress@gmail.com
   E display name: your website name
   Host: smtp.gmail.com
   User: youraddress@gmail.com
   Password: password, remember to click change password button if you are editing any existing account
   SSL: tick to select it
   Use default credentials: uncheck, do not select it
6. Click on save button above.
7. Test the mailing by entering your email id and click on send test email button.




Godaddy Setting



Ensure that this project has Microsoft.Bcl.Build installed and packages.config is located next to the project file

In my Xamarin form application their was dependency Restclient on Microsoft.Bcl.Build Microsoft.Bcl. i just remove all using nuget and ...