‘Xamarin.Android.Support.Design 25.3.1’ is not compatible with ‘Xamarin.Forms 2.3.4.231 constraint: Xamarin.Android.Support.Design (= 23.3.0)’. – How to fix it ?

Why ?

When I was trying to update the NuGet Packages for one of my Xamarin projects, I got an error saying “Unable to resolve dependencies.” and the packages wasn’t updated.

The detailed error message is …

Unable to resolve dependencies. ‘Xamarin.Android.Support.Design 25.3.1’ is not compatible with ‘Xamarin.Forms 2.3.4.231 constraint: Xamarin.Android.Support.Design (= 23.3.0)’.

1 error

Image 1 : Error

The reason for the error was…

The Android project of my Xamarin solution has been configured to Compile using Android 6.0(Marshmallow) API 23.3.0 . But I was trying to update the Android packages for Android 7.1 (Nougat) API 25.3.1.

3 current versions

Image 2 : Current Android application properties(Compile using Android 6.0)

So the target compilation version is not compatible with the updating version of Android packages.

How To Fix the Error ?

To fix the error we have to change the target framework for compile to “Android 7.1(Nougat)”.

Here are Steps to change the target compile framework..

2. go to properties

Image 3 : Right Click on Android Project -> Properties

3 current versions

Image 4 : Current Android application properties(Compile using Android 6.0)

4 select api nouget

Image 5 : Change Compile Android Version to Android 7.1 (Nougat)

When Change the target compilation version of Android , Visual Studio will ask you to restart the project to configure itself…

5 restart project

Image 6 : “Yes” to close and reopen

6 lading

Image 7 : App is loading

7 go to nuget

Image 8 : Again go to NuGet package manager to update Android packages

8 download

Image 9 : Select Android Packages v.25.3.1(or the package showing here)

9 accept

Image 10 : Accept to Agree licence and tearms

9 conform update

Image 11 : You can see changes will be happening (the old packages and new packages). Click OK.

10. installing packages

Image 12 : Then the packages will be downloaded and Install Successfully.

Then Re-Build the project and the app will run successfully…

Thanks !

Fix Error : Incorrect syntax near ‘*=’. In SQL Server (SQL JOINS)

Reason :

I have Migrated  one of my Database from SQL Server 2000 to SQL Server 2016.  And when I was running my applications after the migration of databases, I got some exceptions and then I looked what are the reasons for them..

The Error message was : 

Incorrect syntax near ‘*=’.

I have created a Sample Database with two tables to show you how it occurred and how to fix it.
Here I have wrote a sample quarry to show you how the error has occurred.


SELECT
ID, Name, Age,
CountryName, CountryCapital
FROM Customer cu,Country c
WHERE
cu.CountryID *= c.CountryID

This quarry works in SQL Server 2000 but, it gives and error in SQL Server 2016.

1-qry-sql-2000

Image 1 : LEFT JOIN in SQL SERVER 2000 using  “*=”

2-sql-2016-qry-error

Image 2 : LEFT JOIN in SQL SERVER 2016 using “*=”

Then I looked what is the reason and I got the reason for the error.

The reason is SQL Server 2016 does not support to write quarries with JOINS using ” =*” and “*=” .

But in SQL Server 2000, we can write quarry  with JOINS using  ” =*” and “*=” .

According to above quarry, there is a Left Join.

You can lean more about SQL JOINS using below reference..

w3schools.com/sql/sql_join

Solution :

  1. A one solution is we can change the compatibility level of the database in SQL Server 2016 using database properties.
  2. But the Solution I used is use  “LEFT JOIN” instead of  “*=” .

Then the error has fixed..

But for more information I’ll show you how we can write SQL JOINS in SQL SERVER 2000 and LATER VERSIONS of SQL SERVER 2005 to SQL SERVER 2016.

LEFT JOIN/LEFT OUTER JOIN

LEFT JOIN we can also call as LEFT OUTER JOIN. But both of them gives us the same result. These are use before the WHERE statement.

In SQL Server 2000, we can write LEFT JOIN as “*=”.  But this is using after the WHERE statement.

Then result shows us all records in the LEFT hand side tables and matching values in RIGHT hand side table.

3-using-left-outer

Image 3 : Difference ways to use LEFT JOIN in SQL SERVER 2000

4-using-left-outer

Image 4 : LEFT JOIN in SQL SERVER 2016

RIGHT JOIN/RIGHT OUTER JOIN

RIGHT JOIN  we can also call as the RIGHT OUTER JOIN. But both of them gives us the same result.

In SQL Server 2000, we can write RIGHT JOIN as “=*”.

Then result shows us all records in the RIGHT hand side tables and matching values in LEFT hand side table.

4-ridgt-outer-2000

Image 5 : Different ways to use  RIGHT JOIN in SQL SERVER 2000

5-right-outer-2016

Image 6 : RIGHT JOIN in SQL SERVER 2016

INNER JOIN

INNER JOIN shows only the matching values in both tables. This join we can use in both SQL SERVER version in the same way.

6-inner-join-2000

Image 7 : INNER JOIN in SQL SERVER 2000

7-inner-join-2016

Image 8 : INNER JOIN in SQL SERVER 2016

FULL JOIN/FULL OUTER JOIN

Using FULL JOIN it shows all matching and outmatching  values in both tables. It shows outmatching values as NULL.

FULL JOIN we can use in both SQL SERVERS in the same way.

8-full-join-2000

Image 9 : FULL JOIN in SQL SERVER 2000-2016

 

Thank You !

IF YOU WANT TO TEST THIS, PLEASE CREATE A DATABASE “TestDB”

OR run below quarry.


CREATE DATABASE [TestDB]

and then run this quarry. There and sample data to text your quarries.


USE [TestDB]
GO
/****** Object: Table [dbo].[Country] Script Date: 1/2/2017 6:18:23 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Country](
[CountryID] [int] IDENTITY(1,1) NOT NULL,
[CountryName] [varchar](50) NULL,
[CountryCapital] [varchar](50) NULL
) ON [PRIMARY]

GO
/****** Object: Table [dbo].[Customer] Script Date: 1/2/2017 6:18:23 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customer](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) NULL,
[Age] [int] NULL,
[CountryID] [int] NULL
) ON [PRIMARY]

GO
SET IDENTITY_INSERT [dbo].[Country] ON

INSERT [dbo].[Country] ([CountryID], [CountryName], [CountryCapital]) VALUES (1, N'Sri Lanka', N'Sri Jayawardhanapura')
INSERT [dbo].[Country] ([CountryID], [CountryName], [CountryCapital]) VALUES (2, N'India', N'New Dhilli')
INSERT [dbo].[Country] ([CountryID], [CountryName], [CountryCapital]) VALUES (3, N'Beljium', N'Bruselles')
INSERT [dbo].[Country] ([CountryID], [CountryName], [CountryCapital]) VALUES (4, N'United Kingdom', N'London')
INSERT [dbo].[Country] ([CountryID], [CountryName], [CountryCapital]) VALUES (5, N'United States of America', N'Washington, D.C.')
INSERT [dbo].[Country] ([CountryID], [CountryName], [CountryCapital]) VALUES (6, N'Japan', N'Tokyo')
SET IDENTITY_INSERT [dbo].[Country] OFF
SET IDENTITY_INSERT [dbo].[Customer] ON

INSERT [dbo].[Customer] ([ID], [Name], [Age], [CountryID]) VALUES (1, N'Buddhima', 24, 1)
INSERT [dbo].[Customer] ([ID], [Name], [Age], [CountryID]) VALUES (8, N'Chrystophe', 45, NULL)
INSERT [dbo].[Customer] ([ID], [Name], [Age], [CountryID]) VALUES (9, N'Patel', 30, 2)
INSERT [dbo].[Customer] ([ID], [Name], [Age], [CountryID]) VALUES (10, N'Nikolas', 20, 3)
INSERT [dbo].[Customer] ([ID], [Name], [Age], [CountryID]) VALUES (11, N'Ann', 35, NULL)
INSERT [dbo].[Customer] ([ID], [Name], [Age], [CountryID]) VALUES (12, N'Mike', 50, 4)
SET IDENTITY_INSERT [dbo].[Customer] OFF

Create a File/Directory Transferring App in C#

Reason :

One of a application I’m developing generates many PDF files daily. So we delete them normally once a week or another time. But it is difficult to search files which has generated in a particular date or date range and copy them or delete them to another place. We had to do it manually.

Solution:

SO I created a small app to do it quickly. And I created a small app to show you how to create a example app to copy and delete directories/files from one place to another.

Steps :

1 .Create User Interface.

Here is the user interface I created..

2 drop folder open dialague

Image 1 : UI

We have to select folder path to the app. So I added two folder browse dialogues to select browse folders. You can select “Folder browser dialogue” control form tool box and drag and drop it into above form.

1 folder open dialague

Image 2 : Folder browse control

Then you can see those dialogue controls in bottom panel.

2. We have to Add function to “Source” button and “Destination” button to browse and select source folder path and destination folder path.

3 select directories with delete option

Image 3 : Source and Destination selecting


private void btnSource_Click(object sender, EventArgs e)
 {
 DialogResult result = folderBrowserDialogSourceDir.ShowDialog();
 if (result == DialogResult.OK)
 {
 textBox1.Text = this.folderBrowserDialogSourceDir.SelectedPath;
 }

}

private void btnDestination_Click(object sender, EventArgs e)
 {
 DialogResult result = folderBrowserDialogDestinationDir.ShowDialog();
 if (result == DialogResult.OK)
 {
 textBox2.Text = this.folderBrowserDialogDestinationDir.SelectedPath;
 }
 }

Then when you click one of “Source” or “Destination” buttons, a browser window will popup and you can select any folder.

3 select directories

Image 4 : Folder browser dialague

3. User can check the “Delete after transferring”  check box if he want to delete files from source folder after copy them to destination.

4.Next Add functions to “Transfer files” button  to transfer files when Click it. So I use “Button click” event.

Here is the code in this event.


private void btnTransfer_Click(object sender, EventArgs e)
 {
 try
 {
 string pathDestinationFolder = string.Format(@"{0}", textBox2.Text);

string pathSource = string.Format(@"{0}", textBox1.Text);

if (!string.IsNullOrWhiteSpace(pathSource) && !string.IsNullOrWhiteSpace(pathDestinationFolder))
 {
 DateTime selectedDate = Convert.ToDateTime(dpEffiectiveDate.Text);
 DirectoryCopy(pathSource, pathDestinationFolder, true, selectedDate);

if (chkDelete.Checked)
 {
 DeleteDirectories(pathSource, selectedDate);
 }

lblDirectoriesFound.Text = foundDirectories.ToString();
 lblTransferedFilesCount.Text = createdDirectories.ToString();
 lblDeleted.Text = deletedDirectories.ToString();
 lblNotTransfered.Text = (foundDirectories - createdDirectories).ToString();
 }
 else { MessageBox.Show("Source and destination is required", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); }
 }
 catch (Exception ex)
 {
 MessageBox.Show(MethodBase.GetCurrentMethod() + " -> " + ex.Message);
 }
 }

I have extracted the function to copy directories and files to destination to a method “DirectoryCopy”.


private void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs, DateTime selectedDate)
 {
 try
 {
 #region check exists and create is not exists
 // Get the sub directories for the specified directory.
 DirectoryInfo dir = new DirectoryInfo(sourceDirName);
 DirectoryInfo[] dirs = dir.GetDirectories();

if (!dir.Exists)
 {
 throw new DirectoryNotFoundException(
 "Source directory does not exist or could not be found: "
 + sourceDirName);
 }

// If the destination directory doesn't exist, create it.
 if (!Directory.Exists(destDirName))
 {
 Directory.CreateDirectory(destDirName);
 createdDirectories = createdDirectories + 1;
 dirList.Add(destDirName);
 listViewDirectories.Items.Add("Created Directory -> " + destDirName);
 }

// Get the files in the directory and copy them to the new location.
 FileInfo[] files = dir.GetFiles();
 foreach (FileInfo file in files)
 {
 string temppath = Path.Combine(destDirName, file.Name);
 if (File.Exists(temppath))
 { }
 else
 {
 file.CopyTo(temppath, false);
 listViewDirectories.Items.Add("Coppied file -> " + temppath);
 }
 }
 #endregion
 // If copying subdirectories, copy them and their contents to new location.
 if (copySubDirs)
 {
 foreach (DirectoryInfo subdir in dirs)
 {
 if (subdir.CreationTime.Date == selectedDate.Date)
 {
 foundDirectories = foundDirectories + 1;
 string temppath = Path.Combine(destDirName, subdir.Name);
 DirectoryCopy(subdir.FullName, temppath, copySubDirs, selectedDate);
 }
 }
 }
 }
 catch (Exception ex)
 {
 MessageBox.Show(MethodBase.GetCurrentMethod()+" -> "+ ex.Message);
 }

}

“DirectoryCopy” Method is a recursive function.

Recursive function is a method which calls itself.

for more information go to =>Recursive function

7 use recursive function

Image 5 : Recursive function

The reason is some directories has one or more sub directories. So we have to go through all of them. So we have to loop through all directories in a same war. For that we have to use a Recursive function.

In “DirectoryCopy” method we have to use “FileInfo” class and “Directory“. SO we have to import System.IO namespace.


using System.IO;

[/code</blockquote>
In this method first we are checking directories in the source directory and we can watch information of source directory when debugging it.
<pre>

DirectoryInfo dir = new DirectoryInfo(sourceDirName);

4 file info creation date

Image 6 : File info -> Quick watch

According to my requirement  I get folders and files by its creation date. So I have to use "FileInfo" class to get values.

Then we have to get sub directories in the folder. For that I use GetDirectories() method.


DirectoryInfo[] dirs = dir.GetDirectories();

when debugging the code we can check whether it has sub directories or not.

5 sub directories

Image 7 : Directory info

  • According to above "older is exists and if it is not existing, Then I'm reading a folder to copy files.
  • And then read File information of containing files of resource folder and if its date is my selected date, then copy those files to selected destination.
  • Then show copied files and created folders in the list-box.

After copy files, In  Transfer button click event, then I check the "chkDelete" check box and if it is checked, Then program delete folders from source folder.

DeleteDirectories() is a recursive function too.


private void DeleteDirectories(string pathSource, DateTime selectedDate)
 {
 try
 {
 // Get the subdirectories for the specified directory.
 DirectoryInfo dirs = new DirectoryInfo(pathSource);
 DirectoryInfo[] dirList2 = dirs.GetDirectories();
 foreach (DirectoryInfo subdir in dirList2)
 {
 string subDirname = subdir.FullName;
 if (subdir.CreationTime.Date == selectedDate.Date)
 {
 deletedDirectories = deletedDirectories + 1;
 Directory.Delete(subDirname, true);
 listViewDirectories.Items.Add("Deleted Directory ->" + subDirname);
 }
 else
 {
 DeleteDirectories(subDirname, selectedDate);
 }
 }
 }
 catch (Exception ex)
 {
 MessageBox.Show(MethodBase.GetCurrentMethod() + " -> " + ex.Message);
 }
 }

Then we can see copied files , created directories and deleted directories in the list box.

8 final info

Image 8 : Final Result

And another thing is if an error occurred, System will shows the error message with the Method name. To get the method name that I used ..


MethodBase.GetCurrentMethod()

to use the MethodBase class we have to import ...


using System.Reflection;

To download the code go to Download.

Thanks !

How to Fix Error : SQL Server blocked access to procedure ‘sys.sp_OACreate’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server.

Problem :

When I was executing a stored procedure in a SQL Server 2005 Database from my C# application, it gave me an error and here is the result I saw when I was debug it..

ole auto error 2

Image 1 : Exception Message

SQL Server blocked access to procedure ‘sys.sp_OACreate’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Ole Automation Procedures’ by using sp_configure. For more information about enabling ‘Ole Automation Procedures’, see “Surface Area Configuration” in SQL Server Books Online.

And also I got below error messages with this error. I did not include all information of that message because it is too long..

SQL Server blocked access to procedure ‘sys.sp_OASetProperty’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server…
SQL Server blocked access to procedure ‘sys.sp_OAMethod’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server…
SQL Server blocked access to procedure ‘sys.sp_OADestroy’ of component ‘Ole Automation Procedures’ because this component is turned off as part of the security configuration for this server…

Then I searched solutions to fix this error and I found the solution.

Solution :

According to the message we have to enable the OLE Automation feature in Surface area configuration.

Here are steps to Enable the feature..

0 surface search

Image 2 : Search -> SQL Server Surface Area Configuration in Start menu

1 surface search

Image 3 : Select and click Surface Area Configuration for Features

Then you will enter to another form which contains features. Then Select “OLE Automation”

3 ole uttomation

Image 4 : Select OLE Automation

 

4 enable ole automation

Image 5 : Check the Enable OLE Automation Check box

Then Click “OK”, And Click “Apply”.

But when I click “OK”, I got another error that..

User does not have permission to perform this action.

You don’t have permission to RECONFIGURE statement.

5 enable error

Image 6 : Permission error

To fix this error, I had to give permission to the user..

6 set permissions

Image 7 : Give permission to the user

Then you can apply OLE Automation Feature..

Thanks !