welcome folks
FAQ in android,FAQ in dotnet,DotNet, C#,DOT NET CODE, ASP.NET, VB.NET, TRICKS,Dotnetcode,Android and Latest Technology Articles in VB,Android and ASP.NET

Friday, September 14, 2012

Difference between DBMS and RDBMS?

Data base management system (DBMS) consists of collection of interrelated data and a set of programs to aceess that data in a persistant way. 
It takes care of storing and accessing data specifically related to the application. 

The main objectives of DBMS are 

Data Availability -- available to users in a meaning ful format that can easily access. 
Data Integrity -- Data base, maintains the data in reliable (correctness) manner. 
Data Security -- provides authorization to access the data in different levels at different scenarios. 
Data Independence -- It's nothing but 'abstraction' i.e., to store, update and retrieve data in effecient manner without changing the nature of data. 

RDBMS is nothing but Relational DBMS, uses a collection of tables to represent both data and the relationship among those data. The relational model is a combination of three components as 

Structural Part -- Defines the database as a collection of relations. 
Integrity Part -- maintains integrity using various keys like primary key, foreign key, super key and etc... 
Manipulative Part -- The relational algebra and relational calculus are the tools used to manipulate the data in database by introducing key features like tuples(rows), attributes(columns), keys, cardinalities, Domains and Degrees. 

A relational system may support the following items 
1. Data Definition 
2. View Definition 
3. Data Manipulation 
4. Integrity Constraints 
5. Authorization 
6. Transaction Management 
7. Data Recovery 

The following are main differences: 

1. The speed of operations on data base is very fast in RDBMS compare with ordianry DBMS 
2. RDBMS can be implimented by the concept of relationships (logical mapping). 
3. The concept behind the RDBMS is 'TABLE' but in 'Flat files' are used in DBMS. 

Advantages of polymorphism

Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation

Advantages of polymorphism:

- Same interface could be used for creating methods with different implementations
- Reduces the volume of work in terms of distinguishing and handling various objects
- Supports building extensible systems
- Complete implementation can be replaced by using same method signatures

Advantages of dynamic binding:

- Compiling time is much lower and allows faster development
- The current state of the program is better known to the runtime linker, so that the memory and its resources can easily be reordered
- The addresses symbols which may not be known at compile time, can be resolved by the runtime linker. This process is ideal for networked systems
- Common resources could well be shared instead of duplicating them in each time of execution.

Difference between ref and out parameters in C#

Ref and Out Parameters: 

Both the parameters passed by reference, While for the Ref Parameter you need to initialize it before passing to the function and out parameter you do not need to initialize before passing to function. 

you need to assign values into these parameter before returning to the function. 

Ref (initialize the variable) 
int getal = 0; 
Fun_RefTest(ref getal); 


Out (no need to initialize the variable) 
int getal; 
Fun_OutTest(out getal); 


The out and the ref parameters are used to return values in the same variables, that you pass an an argument of a method. These both parameters are very useful when your method needs to return more than one values. 

In this article, I will explain how do you use these parameters in your C# applications. 

The out Parameter 

The out parameter can be used to return the values in the same variable passed as a parameter of the method. Any changes made to the parameter will be reflected in the variable. 

public class mathClass 

public static int TestOut(out int iVal1, out int iVal2) 

iVal1 = 10; 
iVal2 = 20; 
return 0; 

public static void Main() 

int i, j; // variable need not be initialized 
Console.WriteLine(TestOut(out i, out j)); 
Console.WriteLine(i); 
Console.WriteLine(j); 



The ref parameter 

The ref keyword on a method parameter causes a method to refer to the same variable that was passed as an input parameter for the same method. If you do any changes to the variable, they will be reflected in the variable. 

You can even use ref for more than one method parameters. 

namespace TestRefP 

using System; 
public class myClass 

public static void RefTest(ref int iVal1 ) 

iVal1 += 2; 

public static void Main() 

int i; // variable need to be initialized 
i = 3; 
RefTest(ref i ); 
Console.WriteLine(i); 


Comparisions between Vb.net and C#.net

 Visual Basic .NET

1.Variables can be declared using the WithEvents construct.
2.Auto-wireup of events, VB.NET has the Handles syntax for events.
3.IsNumeric evaluates whether a string can be cast into a numeric value (the equivalent for C# requires using int.TryParse)
4.COM components and interoperability was more powerful in VB.NET as the Object type is bound at runtime,[12] however C#4.0 added the dynamic type which functions as a late bound form of Object
5.Namespaces can be imported in project level, so they don't have to be imported to each individual file, like C#
6.Assigning and comparing variables uses the same token, =. Whereas C# has separate tokens, == for comparison and = to assign a value
7.VB.NET is not case-sensitive.
8.Visual Basic .NET terminates a block of code with End BlockName statements

 C#

1.Allows blocks of unsafe code (like C++/CLI) via the unsafe keyword and support for pointers
2.Partial Interfaces
3.Multi-line comments
4.Static classes
5.Can use checked and unchecked contexts for fine-grained control of overflow/underflow checking
6.String concatenation can be performed using the numeric addition token, +, in addition to the string concatenation token &.
7.C# is case-sensitive.
8.In C#, the braces, {}, are used to delimit blocks.

what is the difference between .dll and .pdb ?

DLL:
dll file stands for Dynamic Link Library. This is the compiled version of the program you write into the programming language.
PDB
.pdb stands for Program database - this generally contains information about the debugging and project state and it gets created in the debug folder of the bin directory only when you compile/build your project in the Debug mode.

Wednesday, September 5, 2012

Usage Interface and its advantage


Interface:
–> If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces.
For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods like Drive(). All child classes like Car Scooter AirPlane SolarCar etc. should derive from this base interface but provide a seperate implementation of the methods and properties exposed by Vehicle.
–> If you want your child classes to implement multiple unrelated functionalities in short multiple inheritance use interfaces.
For e.g. if you are implementing a class called SpaceShip that has to have functionalities from a Vehicle as well as that from a UFO then make both Vehicle and UFO as interfaces and then create a class SpaceShip that implements both Vehicle and UFO .

Use an interface

  • When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.
  • Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.
  • Use an interface to design a polymorphic hierarchy for value types.
  • Use an interface when an immutable contract is really intended.
  • A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality.
For Examble:
interface Shape {

 public double area();
 public double volume();
}
public class Point implements Shape {

 static int x, y;
 public Point() {
  x = 0;
  y = 0;
 }
 public double area() {
  return 0;
 }
 public double volume() {
  return 0;
 }
 public static void print() {
  System.out.println("point: " + x + "," + y);
 }
 public static void main(String args[]) {
  Point p = new Point();
  p.print();
 }
}

Usage Abstract class and its advantage


Abstract Classes
When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.
For e.g. again take the example of the Vehicle class above. If we want all classes deriving from Vehicle to implement the Drive() method in a fixed way whereas the other methods can be overridden by child classes. In such a scenario we implement the Vehicle class as an abstract class with an implementation of Drive while leave the other methods / properties as abstract so they could be overridden by child classes.
The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share.
For example a class library may define an abstract class that is used as a parameter to many of its functions and require programmers using that library to provide their own implementation of the class by creating a derived class.

Use an abstract class

  • When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. ( COM was designed around interfaces.)
  • Use an abstract class to define a common base class for a family of types.
  • Use an abstract class to provide default behavior.
  • Subclass only a base class in a hierarchy to which the class logically belongs.

For exapmple:
abstract class Shape {

 public String color;
 public Shape() {
 }
 public void setColor(String c) {
  color = c;
 }
 public String getColor() {
  return color;
 }
 abstract public double area();
}
public class Point extends Shape {

 static int x, y;
 public Point() {
  x = 0;
  y = 0;
 }
 public double area() {
  return 0;
 }
 public double perimeter() {
  return 0;
 }
 public static void print() {
  System.out.println("point: " + x + "," + y);
 }
 public static void main(String args[]) {
  Point p = new Point();
  p.print();
 }
}

Friday, August 31, 2012

Difference Between Abstract Class & Interface in .net?

Abstract Classes:- 

-->abstrct methods means only method is defined.body undefined.(Not implented) just like skelton 

-->non-abstract methods means method body is defined 

just see below.. 

Sample_Parent is one class having 2 methods : 

1--method1()--this is abstract method 
2--method2()--this is non abstract method 

public abstract class Sample_Parent 

public void method1(); 

public void method2() 

// write code here 




the above clss having One abstract method is there,so should class is prefixed with One keyword 'abstract'.otherwise we wil get Compile time error. 

Abstarct class having Some are abstrct methods and some are non-abstrct methods. 

some People like this also Abstact class containg 0 or more number of Abstract methods!! 

Ex:HttpServlet. 

clear right now.. 

--> Now When we wil move For Abstract Class?? 

We have some of the Methods implementation we had..and we dont have some of the methods implementation 

so then this time we use Abstract classes.. 

Suppose i write one example on This situtation:- 

the above class is Abstart class we are unable to create the Object so we have to that abstrct method make it as a Non-abstrct method in Child class. 

Class Sample_child extends Sample_Parent 

public void method2() 

//write code here.. 

public static void main(String args[]) 

//here we have to create Child class object.. 




and illegal combination of abstarct: 

1.private--abstarct classes must inheritd.so the scope must public,default,protected. 
2.sealed Or Final--the abstarct methods are must ovvrride in child classes but final ignored inheritance concept. 
simply abstarct says am implementing in child clss but final is compltly Opposite. 
So these are Illegal combination. 
*************************************************************************************************** 


Now Waht Is Interface:- 

Interface is 100% Abstaract Methods(All are Need to Implement to Child Classes) 


in interface concept there is no chanse of Non-abstract methods. 

and similar to Abstarct classes we are unable to create Object to Interface. 

interface is a keyword.. 

am trying to write a Sample program on interface.. 

interface Sample 

public void Method1(); 
void method2(); 


above Sample is Interface having 2 methods..so thse are ready to implement to in child classes 


public class Sapmle_clss implements Sample 

public void method1() 

//write code here.. 



public void method2() 

//write code here.. 


public static void main(string ar[]) 

//here we have to create object to Class. 



We Dont have Any Implementaion so we move for Ineterface. 

Example: 
Any API's.. 

JDBC--Api relesed by Sun people 
implemnted by OraclePeople,mysql,DB2,etc. 

Servlet API--Relesed by Sun People Implemnetd By Apache,Weblogic, guys,,, 

in interface methods are By default:public, abstrct 
in interface Varibles are By default:public ,static, final 


Advantges Abstract class over Interface:- 

Multiple inheritance Concept not achiving through Abstract Classes 

But Through Interface We can Achive Multiple Inheritance 

How to send SMS to Multiple User in asp.net?

Please Refer the below links.

 http://www.codeproject.com/Articles/20064/How-to-Send-SMS-Messages-from-C-using-an-SQL-Datab

what is the uses of getElementById and ClientId In Asp.net

if (document.getElementById('<%=txtUserId.ClientId %>').value == "") { 
alert('Username is Mandtory'); 
return false; 


from your question 

<%=txtUserId.ClientId %> this statement is used to access server control ID in asp.net from javascript code & plz use this 
<%=txtUserId.ClientID %> 
in place of this <%=txtUserId.ClientId %> check difference

Wednesday, August 29, 2012

How to get Contact Number or list in android application?


There are three steps to this process.
1) Permissions
Add a permission to read contacts data to your application manifest.
<uses-permission android:name="android.permission.READ_CONTACTS"/>
2) Calling the Contact Picker
Within your Activity, create an Intent that asks the system to find an Activity that can perform a PICK action from the items in the Contacts URI.
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
Call startActivityForResult, passing in this Intent (and a request code integer, PICK_CONTACT in this example). This will cause Android to launch an Activity that's registered to support ACTION_PICKon the People.CONTENT_URI, then return to this Activity when the selection is made (or canceled).
startActivityForResult(intent, PICK_CONTACT);
3) Listening for the Result
Also in your Activity, override the onActivityResult method to listen for the return from the 'select a contact' Activity you launched in step 2. You should check that the returned request code matches the value you're expecting, and that the result code is RESULT_OK.
You can get the URI of the selected contact by calling getData() on the data Intent parameter. To get the name of the selected contact you need to use that URI to create a new query and extract the name from the returned cursor.
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
  super.onActivityResult(reqCode, resultCode, data);

  switch (reqCode) {
    case (PICK_CONTACT) :
      if (resultCode == Activity.RESULT_OK) {
        Uri contactData = data.getData();
        Cursor c =  managedQuery(contactData, null, null, null, null);
        if (c.moveToFirst()) {
          String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
          // TODO Whatever you want to do with the selected contact name.
        }
      }
      break;
  }
}

How to Close and Hide Android Soft KeyBoard?


You can force Android to hide the virtual keyboard using the InputMethodManager, callinghideSoftInputFromWindow, passing in the token of the window containing your edit field.
InputMethodManager imm = (InputMethodManager)getSystemService(
      Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

How to declare global variable in android?


class MyApp extends Application {

  private String myState;

  public String getState(){
    return myState;
  }
  public void setState(String s){
    myState = s;
  }
}
class Blah extends Activity {

  @Override
  public void onCreate(Bundle b){
    ...
    MyApp appState = ((MyApp)getApplicationContext());
    String state = appState.getState();
    ...
  }
}