# Posts Tagged bikash

### Unable to update the EntitySet ‘yourTableName’ because it has a DefiningQuery and no element exists in the element to support the current operation.

Posted by Bikash Karmokar in ASP.NET, C# on December 5, 2012

Recently i am switching to MVC4 with Razor view engine for ASP.NET, C# web application. Tomorrow i was developing a blogging site where there were some works related to database. There i have created a table with 4 columns but none of them were made primary key.

When i tried to run the application the visual studio 2012 shows the error **“Unable to update the EntitySet ‘UserTable’ because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.” ***Here UserTable was my table name.*

The database was sql server compact edition of visual studio 2012. I became confused about the error because this type of table with no primary key works well before. After a while i came to know that the problem was because of the lacking of primary key in the table. when i mark one of the columns as a primary key then the project run without error. This type of error was new to me so i thought to write down here so later on it may be helpful to someone like me.

**Summary of the error and solution:**

**Problem:** No primary key in the table

**Solution:** Add a primary key in the table

Happy Coding……….

Bikash, Software Engineer.

### Find your GrameenPhone account balance or remaining MegaBytes for internet uses using Modem insted of Mobile phone

Posted by Bikash Karmokar in Miscellaneous on February 6, 2012

Most of us feel too much burden when we have to see our account balance or remaining megabytes because of changing simcard from modem to mobile phone. That’s why, to remove our burden we can use USSD activator plugins for GrameenPhone modem software. By using this we can find our account balance or remaining megabytes from the software. Then we do not need any mobile phone for knowing these necessary information. We can also know other information entering appropriate USSD numbers. This is an useful plugins for the GP users. Anyone can try this for better feelings.

To download the plugins click here. Install the plugins then restart the modem software. Then you will find USSD tab. Click on the that tab and start using.

Thanks for reading this post.

Bikash

### Prolog code for maximum, minimum, oddeven, permutation and nth element

Posted by Bikash Karmokar in Prolog on August 2, 2011

**Maximum number:**

max_list([H|T],M):-max_list(T,H,M).

max_list([],C,C).

max_list([H|T],C,M):-

C2 is max(C,H),

max_list(T,C2,M).

**Input and output:**

%max_list([4,5,1,9],M).

%M=9

**Minimum number:**

minl([Only], Only).

minl([Head|Tail], Minimum) :-

minl(Tail, TailMin),

Minimum is min(Head, TailMin).

Input = minl([4,5,1,2,9],X).

**Odd or even:**

odd_even(X):- X mod 2 =:= 0,

write(‘even number’),nl.

odd_even(X):- write(‘odd number’),nl.

**Permutation:**

perm(List,[H|Perm]):-delete(H,List,Rest),perm(Rest,Perm).

perm([],[]).

delete(X,[X|T],T).

delete(X,[H|T],[H|NT]):-delete(X,T,NT).

**Input:**

perm([1,2,3],B).

**Nth element:**

nth(Count, Item, [_|Tail]):-

Count > 1,

Count0 is Count-1,

nth(Count0, Item, Tail).

nth(1,Head,[Head|_]).

%nth(pos,num.list).

%pos=2

%num=3

%ache kina chke kre yes or no rslt

%nth(2,3,[1,3,5,6]).

%Yes

%nth(2,3,[1,1,5,6]).

%No

### Prolog code for fibonacci series and number

Posted by Bikash Karmokar in Prolog on August 2, 2011

**Finding fibonacci series:**

:- dynamic(stored/1).

memo(Goal) :-

stored(Goal) -> true;

Goal, assertz(stored(Goal)).

fib(1,1) :- !, write(‘1, ‘).

fib(2,1) :- !, write(‘1, ‘).

fib(N,F) :-

N1 is N-1, memo(fib(N1,F1)),

N2 is N-2, memo(fib(N2,F2)),

F is F1 + F2,

write(F), write(‘, ‘).

Input = fib(7,X).

Output: 1, 1, 2, 3, 5, 8, 13

**Other fibonacci code:**

fib(0,0).

fib(1,1).

fib(X, Ans) :- Xm1 is X – 1 ,Xm2 is X – 2 ,

fib(Xm1, Sub1), fib(Xm2, Sub2),

Ans is Sub1 + Sub2.

fib(0,A). means A=0; 0 tomo fibonacci number is 0

fib(7,A). A=13; 7 th fibonacci number is 13

fibonacci series: 0,1,1,2,3,5,8,13,21,34,55,89,144;

**another one**:

fib_for(N,_,N).

fib_for(N1,N2,N):-

N3 is N1+N2,

fib_for(N2,N3,N).

%fib_for(FirstNumber, SecondNumber, Result).

% Example: ?-fib_for(1,1,Result).

%at first have to provide two fibonacci number then have to start execution, when executing have to press ; for next fibonacci number.

### Prolog code for prime number, power calculation and factorial

Posted by Bikash Karmokar in Prolog on August 2, 2011

**Checking prime number:**

divisible(X,Y):-

N is Y*Y,

N =< X,

X mod Y =:= 0.

divisible(X,Y):-

Y < X,

Y1 is Y+1,

divisible(X,Y1).

isprime(X):-

Y is 2, X > 1, \+divisible(X,Y).

Input: isprime(7).

Output: Yes

**Finding power of a number:**

power(0,N,0):- N>0.

power(X,0,1):- X>0.

power(X,N,V):-X>0,N>0,N1 is N-1,power(X,N1,V1), V is V1*X.

Input: power(2,4,P).

Output: V=16

**Finding factorial of a number:**

fact(0,1).

fact(X,Y):-

X1 is X-1,

fact(X1,Z),

Y is X*Z.

Input: fact(3,X).

Output: X=6