Tuesday, 28 February 2017
Troubleshooting Cisco VPN client
Before starting troubleshooting, Let us see what VPN
is and what it requires to perform its intended function.
A VPN connection is the extension of a private network
that includes links across shared or public networks, such as the Internet. VPN
connections (VPNs) enable organizations to send data between two computers
across the Internet in a manner that emulates the properties of a
point-to-point private link.
During installation
process, an error 0x8004a029: Couldn't install the network component", might
have occurred.
Error 0x8004a029 means that the maximum number of filter devices for the system has been reached. Other similar software (3rd party firewalls, etc.) install filters. You can either attempt to remove other software that has installed a filter, or attempt to increase the following registry entry value to allow more filters to be installed.
Error 0x8004a029 means that the maximum number of filter devices for the system has been reached. Other similar software (3rd party firewalls, etc.) install filters. You can either attempt to remove other software that has installed a filter, or attempt to increase the following registry entry value to allow more filters to be installed.
A filter
driver is a Microsoft Windows driver that extends or modifies the
function of peripheral devices or supports a specialized device in
the personal computer. It is a
driver or program or module that is inserted into the existing driver stack to perform some specific function.
Hence in order to install VPN
properly increase in maximum number of network filters is required.
Now let us see the steps to change
the system’s registry value to increase the maximum number of filter so that
VPN client could install filters in conjunction with its network component.
1. Open
Registry Editor.
![]() |
| Reg Edit |
2. Extend
System
tab.
| System tab Regedit |
3. Extend
CurrentControlSet tab.
| Current Control Set Regedit |
4. Extend control
tab.
| Control Regedit |
5. Seek
down and click on Network
tab.
| Network Tab Regedit |
6. Double
tap MaxNumFIlters option
present on the right side partition of the registry editor.
| Network Filters |
7. Change
Value data from 8(default value) to 14 and tap ok.
8. Now
restart your system and try re-installing VPN client.
| Max Num Filters |
Note: If you
don't see MaxNumFilters name, you can create it with the Type being REG_DWORD
as shown below.
Monday, 27 February 2017
Insertion Sort
It is one of the well known sorting algorithm which is really effective when it comes to sort small number of elements.
Insertion Sort's real life co-relation
- Its implementation is similar to the way one might sort hand of king higher playing cards.
- Initiate with an empty left hand and cards face down on the table.
- Pick one card at once from the table and insert it at its rightful place in the left hand.
- In order to find the correct position of a card, compare it with all the cards already present in the left hand in the right to left direction.
- Note at all times the cards in the left hand are always sorted.
Let us try to understand insertion sort with the help of an example.....
Suppose we have a list of 10 numbers as: 10,32,5,3,98,87,90,45,1,49
- Let us start from 10, Since there is nothing in the left hand so we will directly put 10 in our left hand.
- Next we'll pick 32 from the table, and compare it with 10, since it is larger than 10 so its position will be after 10 in our left hand.
- Now the next number is 5, We'll compare from right to left till we get a number smaller than 5 or we reach the end of the list i.e the left most end, since 5 is smaller than 32 so 32 will be shifted at 5's place,again 5 is smaller than 10 also,hence 10 will be shifted at 32's place,and now we reach the left most end and hence will place 5 over there,so finally there are 5,10,32 on the left hand and 3,98,87,90,45,1,49 on the table.
- Next we'll pick 3, and compare it from right to left direction, after comparing we'll get 3,5,10,32 in the left hand and rest on the table.
- Picking up 98 we don't have any number smaller than this,hence will place 98 at the right most end of left hand making the new list in left hand as 3,5,10,32,98.
- 87 the next number to be inserted before 98 in the left hand making the list as 3,5,10,32,87,98.
- 90 to occupy the position after 87 and before 98, making left hand list as, 3,5,10,32,87,90,98.
- 45 to be picked next from table will be placed after 32 and before 87 to update the list as, 3,5,10,32,45,87,90,98.
- 1 to be placed at the beginning updated the list as 1,3,5,10,32,45,87,90,98.
- Finally the last number on the table to be placed between 45 and 87, making the final sorted list as: 1,3,5,10,32,45,49,87,90,98.
| Insertion Sort Passes |
Source Code:
#include<stdio.h>
# define MAX 20
void main()
{
int soin[MAX],i,j,n,k,swap_var,key;
printf("Enter the number elements needs to be sorted:");
scanf("%d",&n);
printf("\nEnter the list of %d,you want to sort:",n);
for(i=0;i<n;i++)
{
scanf("%d",&soin[i]);
}
for(i=1;i<n;i++)
{
key=soin[i];
j=i;
while(j>=1&&key<soin[j-1])
{
soin[j]=soin[j-1];
j--;
}
soin[j]=key; // Key inserted at its proper place
printf("\nAfter pass %d list is",i);
for(k=0;k<n;k++)
printf(" %d",soin[k]); //Just for display purpose
}
printf("\nFinal Sorted list is:\n");
for(i=0;i<n;i++)
{
printf(" %d",soin[i]);
Note use of macros is recommended so that code can be made flexible.
Thursday, 23 February 2017
Column alphabets of excel from column numbers in c#
Today we'll discuss method logic to return the column alphabet from the column number as in Microsoft excel in c#. We'll build a generic logic so that it can be implemented in any programming language with change in syntax off course.
For example
If we pass 5 as column number, our method should return E or if we pass 28 our function should return AB.....
So what is the purpose for implementing such a logic? While making an excel sheet programatically, sometimes it is required to implement formulas in a specific cell of excel and respective column alphabetic name is to be listed in the formula expression. So using this logic we can implement formulas dynamically in excel cells.
For example
If we want to apply formula to cells present in column 1 to column 10 as column 1 uses its column members in expression and column 2 uses its members and so on then we'll loop through 1 to 10 and call our function each time incrementing its argument by 1.
| Excel Column Alphabets |
Source Code:
while (count <=55 )
{
cname = get_name(count);
String form = "=" + "SUM(" + cname + "8" + "," + cname + "17" + "," + cname + "53" + "," + cname + "62" + "," + cname + "71" + "," + cname + "80" + "," + cname + "89" + ")";
String form1 = "=" + "SUM(" + cname + "9" + "," + cname + "18" + "," + cname + "54" + "," + cname + "63" + "," + cname + "72" + "," + cname + "81" + "," + cname + "90" + ")";
ExcelApp.Cells[92, count].Formula = form;
ExcelApp.Cells[93, count].Formula = form1;
count++;
}
private String get_name(int c_no)
{
int div = c_no;
string columnName = String.Empty;
int mod;
while (div > 0)
{
mod = (div - 1) % 26;
columnName = Convert.ToChar(65 + mod).ToString() + columnName;
div = (int)((div - mod) / 26);
}
return columnName;
}
The above logic csn be implemented in any programming language just by changing the syntax.
Now let us try to understand the logic:
1. We'll send column no. as 1 to 55 as arguments to our method off course one bt one hence we will make th function call in a loop and catch the return value in a string identifier.
2. Now let us try to understand exhaustively, suppose our method got the argument "28".
3. So c_no(method local variable) got the value 28.
4. div is assigned value of c_no. i.e 28.
5. A string is initialized with name columnName along with an integer variable declared as mod.
6. Now div value is 28 hence we'll loop till it is greater than 0.
- Now inside the loop block we'll assign mod value as (div-1)%26(A-Z) i.e mod will be 1
- Column name will be assigned Ascii value of 65+mod, concatenated with column name retrieved in previous loop traversal i.e column name will be B(ascii value of 66).
- div will be (int)(div-mod)/26 i.e 1 which is greater than zero and hence the loop continues with div as 1.
- Now inside the loop block we'll assign mod value as (div-1)%26(A-Z) i.e mod will be 0
- Column name will be assigned Ascii value of 65+mod, concatenated with column name retrieved in previous loop traversal i.e column name will be A(ascii value of 65)+B(previous column name)=AB.
- div will be (int)(div-mod)/26 i.e 0(Type casting to integer) and since it is not greater than 0,hence the loop exits.
The above logic csn be implemented in any programming language just by changing the syntax.
Wednesday, 22 February 2017
On 00:17 by Vardan Kumar in C# 5 comments
Excel sheet from data table and data set in c#
Excel workbook is one of the most popular MS office application, especially when it comes to make a report. Hence it is recommended to learn how to make an excel sheet in c# developing environment.
Before we continue let us briefly understand what a DataSet is:
A DataSet is a collection of data tables objects or instances on which we can set relation through data relation objects and hence navigate through data table architecture.
How DataSet is declared or initialized in c#?
System.Data.DataSet dt_csp = null;
Next we'll declare our data table:
System.Data.DataTable tb_csp = new System.Data.DataTable("SFY" + sfy.ToString());
Here the DataTable method argument is its name which will also be used as the name of our excel sheet which we are just about to make.
sfy is an integer variable which can be set dynamically as financial year value.
We can populate our data table using:
tb_csp.Columns.Add("cspassion Column String"); // To add columns to data table
Note for data table the columns name should be unique otherwise it will throw an exception
tb_csp.Rows.Add("cspassion Row String"); // To add rows to data table
After populating the data table, add it to data set.
dt_csp = new DataSet("General");
dt_csp.Tables.Add(tb_csp);
Hence our data table is added to data set colection.
So we are ready with our data set, now let us populate our excel sheet
- Firstly we have to make an object of Microsoft office excel application Microsoft.Office.Interop.Excel.Application ExcelCsp = new Microsoft.Office.Interop.Excel.Application();
- Now we'll create a workbook. Workbook xlWorkbook = ExcelCsp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
- Now we'll create a data table collection and add our data set tables to it. DataTableCollection collection = dataSet.Tables;
- Now we'll initialize Sheets and worksheets and create our excel sheets.
Sheets xlSheets = null
Worksheet xlWorksheet = null;
//Create Excel Sheets
xlSheets = ExcelCsp.Sheets;
xlWorksheet = (Worksheet)xlSheets.Add(xlSheets[1], Type.Missing, Type.Missing, Type.Missing);
7.Now we'll add our collection first table to a data table and give our worksheet the same name as data table.
System.Data.DataTable table_csp = collection[0];
xlWorksheet.Name = table_csp.TableName;
8.Now we'll add columns to our excel sheet.
for (int j = 1; j < table_csp.Columns.Count + 1; j++)
{
ExcelCsp.Cells[1, j] = table.Columns[j - 1].ColumnName;
}
9. Now we'll store value of each row and column to excel sheet.
for (int k = 0; k < table_csp.Rows.Count; k++)
{
for (int l = 0; l < table_csp.Columns.Count; l++)
{
ExcelCsp.Cells[k + 2, l + 1] =
table_csp.Rows[k].ItemArray[l].ToString();
}
Source Code:
Microsoft.Office.Interop.Excel.Application ExcelCsp = new Microsoft.Office.Interop.Excel.Application();
Workbook xlWorkbook = ExcelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
DataTableCollection collection = dataSet.Tables;
Sheets xlSheets = null;
Worksheet xlWorksheet = null;
//Create Excel Sheets
xlSheets = ExcelCsp.Sheets;
xlWorksheet = (Worksheet)xlSheets.Add(xlSheets[1],
Type.Missing, Type.Missing, Type.Missing);
System.Data.DataTable table_csp = collection[0];
xlWorksheet.Name = table_csp.TableName;
for (int j = 1; j < table_csp.Columns.Count + 1; j++)
{
ExcelCsp.Cells[1, j] = table_csp.Columns[j - 1].ColumnName;
}
for (int k = 0; k < table_csp.Rows.Count; k++)
{
for (int l = 0; l < table_csp.Columns.Count; l++)
{
ExcelCsp.Cells[k + 2, l + 1] =
table_csp.Rows[k].ItemArray[l].ToString();
}
}
//We have populated our excel sheet successfully, but what now we have to save it also....
xlWorkbook.SaveAs("path");
// And finally make our excel sheet visible
ExcelCsp.Visible = true;((Worksheet)ExcelCsp.ActiveWorkbook.Sheets[ExcelCsp.ActiveWorkbook.Sheets.Count]).Delete();
Monday, 20 February 2017
On 04:16 by Vardan Kumar in C tutorial 7 comments
Addition,Subtraction,Multiplication by 2 and division by 2 without using +,-,* and / in c
When it comes to enhance the software development skills, the magic lies in logic building. So here we are going to discuss a program with can add two numbers,subtract two numbers,multiply by 2 and division by 2,seems simple but here's a twist we can not use +,-,* and / operators for the same.
- Addition:
For the pupose of addition of two numbers off course not by using + operator, we will use ++(increment) as well as --(decrement) operator. Simple! isn't it?. And for the logic we will just decrement one of the number till it gets 0(in a loop) and increment the another one. Let us review the function definition for the same.
int add(int inum1,int inum2)
{
while(inum2--)
{
inum1++;
}
return inum1;
}
2. Subtraction:
Similarly for subtraction we'll use the combination of increment(++) as well as decrement(--) operators since we can not use '-' operator. And for the logic we'll just decrement onre of the number till it gets '0' and decrement the another one. Let us review function definition for the same.
int subtract(int inum1,int inum2)
{
while(inum2--)
{
--inum1;
}
return inum1;
}
int subtract(int inum1,int inum2)
{
while(inum2--)
{
--inum1;
}
return inum1;
}
3. Multiplication By 2:
For the purpose of multiplication by 2 we'll use already built addition function. Got the strike, yeah we will pass the number we want to multiply with '2' as arguments while calling "add" function and store the return value of add function in a pocket variable. Let us review the function definition for the same.
int mulby2(int inum)
{
int pocket;
pocket=add(inum,inum);
return pocket;
}
4. Division By 2:
For the purpose of division by 2 we'll use bitwise operators, yes we got it right, the right shift operator(>>), we'll just right shift the number by '1' we want to divide with 2, hence we'll get the quotient for the division and if we want to get the remainder, off course we know we can use modulus operator(%)
int divby2(int inum)
{
inum = inum>>1;
return inum;
}
Source Code:
#include<stdio.h>
int add(int inum1,int inum2)
{
while(inum2--)
{
inum1++;
}
return inum1;
}
int subtract(int inum1,int inum2)
{
while(inum2--)
{
--inum1;
}
return inum1;
}
int mulby2(int inum)
{
int pocket;
pocket=add(inum,inum);
return pocket;
}
int divby2(int inum)
{
inum = inum>>1;
return inum;
}
void main()
{
int num1,num2,num,ap,as,am,ad;
printf("Enter the two numbers for addition and subtraction:");
scanf("%d %d",&num1,&num2);
printf("\nEnter number for mul and div by 2:");
scanf("%d",&num);
ap=add(num1,num2);
as=subtract(num1,num2);
am=mulby2(num);
ad=divby2(num);
printf("\nResult of addition is:%d",ap);
printf("\nResult of subtraction is:%d",as);
printf("\nResult of multiplication by 2 is:%d",am);
printf("\nquotient of division by 2 is:%d and remainder is %d",ad,num%2);
}
Tuesday, 14 February 2017
On 22:57 by Vardan Kumar in C# 3 comments
Progress Bar in C# Windows form application
Why Progress Bar is important?
Lets imagine ourselves as a user of an application. Now lets suppose our application is taking a minute or two to do its desired purpose. Meantime application is doing nothing, we are just seeing a dumb windows form in front of you, what would we think...Well yes we would think that the application hung up in about 20 to 30 sec or less and would try to interrupt the application progress either by closing it or opening task manager and what not?
Hence it is considered a good practice as a developer to tell our user the progress of our application. Hope we have understood the main purpose of a progress bar, apart from it makes our GUI look better.
Including a progress bar is not just enough, incorporating an efficient progress bar which should move continuously is also necessary as suppose if progress bar has stopped progressing for about 20-30 sec, again we as a user would think that application has stopped responding.
Also additionally,
- if we can tell the user what application is currently doing that would be nice.
- We will also try to increase the progress of the progress bar linearly or monotonously as far as possible which we can do by increasing its progress in a loop.
![]() |
| Progress Bar c# |
try
{
Microsoft.Office.Interop.Excel.Application ExcelApp = new Microsoft.Office.Interop.Excel.Application();
Workbook xlWorkbook = ExcelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
DataTableCollection collection = dataSet.Tables;
Sheets xlSheets = null;
Worksheet xlWorksheet = null;
//Create Excel Sheets
xlSheets = ExcelApp.Sheets;
xlWorksheet = (Worksheet)xlSheets.Add(xlSheets[1],
Type.Missing, Type.Missing, Type.Missing);
System.Data.DataTable table = collection[0];
xlWorksheet.Name = table.TableName;
for (int j = 1; j < table.Columns.Count + 1; j++)
{
ExcelApp.Cells[1, j] = table.Columns[j - 1].ColumnName;
}
lbl_Cmpltd.Text = "Preparing Excel Sheet";
// Storing Each row and column value to excel sheet
for (int k = 0; k < table.Rows.Count; k++)
{
prg_TaskProgress.Value = prg_TaskProgress.Value + 1;
lbl_OnGng.Text = "Adding Rows("+k.ToString()+"/"+(table.Rows.Count-1).ToString()+")";
for (int l = 0; l < table.Columns.Count; l++)
{
ExcelApp.Cells[k + 2, l + 1] =
table.Rows[k].ItemArray[l].ToString();
}
}
lbl_Cmpltd.Text = "Adding Rows";
Features and Logic
- Above Source code populates an excel sheet via data tables in data set
- In above code table.rows.Count gives the total number of rows and hence our loop runs the same number of times
- k will take values from 0 to total number of rows in data table
- Progress Bar's value is incremented by '1' each time the loop is executed.
- Progress Bar's maximum value should be set in its properties and its value should not exceed that maximum value or else it will throw an exception.
- We can also change the style of our progress bar,I prefer continuous style for elegant looks.
- Providing labels for what currently our application is performing makes our application more sophisticated.
On 02:13 by Vardan Kumar in C tutorial 4 comments
Function which takes string and a character as input and returns the next position of character each time it is called
Today we'll define a function with following properties:-
- Return type of the function will be int i.e. the function will return an integer value.
- Function will accept two arguments.
- One of the argument will be a char and another char array.
Now let us try to understand our purpose with the help of an example......
Suppose our input string is: The domain name of this website is www.cspassion.com
and Suppose our input character is: 'i'
Then our function should do the following...
After 1st call-> 9
After 2nd call->22
After 3rd call->29
After 4th call->33
After 5th call->46
There by if any more calls are made to the function then "No more occurrences" kind of message should be displayed.
Hope the purpose is understood, lets give it a shot before proceeding further......
Logic:
- We'll use infinite while loop which will include switch-case control inside it.
- One case will make a call to function and another will bt he exit case.
- We'll use static variable as function's local variable so that its previous value is not lost whenever a new call is made to the function.
| Output String-Character position Program |
Source code
#include<stdio.h>
int get_position(char linput,char linput1[100])
{
static int count=0;
while(linput1[count]!=linput)
{
count=count+1;
}
count=count+1;
return count;
}
void main()
{
int count=0,pocket,choice,i,count1=0;
char input,input1[100];
printf("Enter the String\n");
fflush(stdin);
fgets(input1,sizeof(input1),stdin);
printf("\nEnter the character whose position you want to return:");
scanf("%c",&input);
for(i=0;i<strlen(input1);i++)
{
if(input1[i]==input)
count1++;
}
while(1)
{
printf("\nEnter 1 to call the function,it would be your call '%d'\n",count+1);
printf("\nEnter 2 for exit\n");
printf("Enter your choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
count=count+1;
if(count<=count1)
{
fflush(stdin);
pocket=get_position(input,input1);
printf("\nAfter call %d,the position is %d\n",count,pocket);
}
else{
printf("No more occurrences of the specified character");
exit(1);
}
break;
case 2:
exit(1);
break;
default:
printf("Invalid input\n");
break;
}
}
}
Sunday, 12 February 2017
Reading multiple columns from database
Most of the application development isn't possible without using a Database Management System since our aim is never to build a normal application, our aim is to build a sophisticated application. So database applications must be included within our developing environment. While fetching information or values from our database we might come across retrieving values from multiple columns, usually can be done if we have same query structure for data retrieval i.e. conditions applied on data are similar. Here we'll be using oracle DBMS but you can use any for the same. Hence instead of using multiple queries to retrieve data from multiple columns, we'll use a single query to read multiple columns.
In order to fetch data from database we'll use Oracle data reader and loop the data table until the last record. Before proceeding to source code we must know how reader works?
Reader is basically used to retrieve row values. For explanation purpose let us imagine the data table as a matrix[i x j].
reader[0] will read the value at [1,1]
reader[1] will read value at [1,2]
.
.
.
.
.
reader[j] will read value at [1,j]
When the full row is read then the reader will jump to the next row and read till the full row is fetched.
| Reading Multiple Columns from database c# source code |
Now assuming that we all have basic knowledge for database, function of oracle data reader and basics to retrieve values from database in c#, we'll jump to the source code.
// Variable Declaration
List<string> AN = new List<string>();
List<string> BN = new List<string>();
List<string> CN = new List<string>();
List<string> DN = new List<string>();
List<string> EN = new List<string>();
List<string> FN = new List<string>();
List<string> GN = new List<string>();
List<string> HN = new List<string>();
using (OracleConnection connection = new OracleConnection(sConnectionString))
{
connection.Open();
using (OracleCommand command = new OracleCommand("SELECT NVL(AName,0),NVL(BName,0),NVL(CName,0),NVL(DName,0),NVL(EName,0),NVL(FName,0),NVL(GName,0),NVL(HName,0) FROM T_CSP where REP_DATE BETWEEN :d1 AND :d2 order by REP_DATE", connection))
{
command.Parameters.Add(new OracleParameter(":d1", dt1));
command.Parameters.Add(new OracleParameter(":d2", dt2));
command.BindByName = true;
using (OracleDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
AN.Add(reader[0].ToString());
BN.Add(reader[1].ToString());
CN.Add(reader[2].ToString());
DN.Add(reader[3].ToString());
EN.Add(reader[4].ToString());
FN.Add(reader[5].ToString());
GN.Add(reader[6].ToString());
HN.Add(reader[7].ToString());
}
}
connection.Close();
}
}
Points at a Glance
- sConnectionString is your connection string which can be set dynamically or statically or in your application's configuration file.
- Any valid SQL Query can be used.
- d1 and d2 are the parameters, more precisely date parameters. If dynamic fiscal date is to be set check out the link below.
- AN is a list string that will contain all the fields of column AName in table T_CSP between date d1 and d2 order by rep_date. Similarly BN is a list string that will contain all the fields of column BName in table T_CSP between date d1 and d2 order by rep_date.
- Rest all the list strings will have fields of their respective columns.
This is how we can read multiple columns in different list strings.
Subscribe to:
Posts (Atom)
Search
Popular Posts
-
File Versioning C# File versioning, saving file with unique file name in c# File versioning allows a user to have several versions of ...
-
Troubleshooting Cisco VPN client Before starting troubleshooting, Let us see what VPN is and what it requires to perform its intended f...
-
Evolution-Mobile Phones With the development of portable technology,wireless communication has so evolved that (According to the announce...
-
Text Box Hint in c# Windows Form Application Text Box Hint in c# Windows Form Application While developing a windows form applicat...
-
Unable to set the Freeze Panes property of Window Class C# It is generally easy to resolve the compile time errors because the reason fo...




