Monday, 30 July 2012

How to get input in character type array in java

Hi ............
There are many way to get input in java. Java works on two type of stream 1. Character Stream 2. Byte Stream
Java treats Char data type different form c and c++. In C/C++ char data type hold 7 bit ASCII Character which is 0 to 127 characters but java char data type works on Unicode.
  • takes one character from user and return correspondence int value
  • for hold it we have to type cast in char
  • stop when user press enter its take it '\n'
class CharInput
           public static void main(String args[]) throws Exception
                  char ar[]=new char[5];
                  int i;
            static char getChar() throws Exception
                   char ch=(char);
                   return ch;
             static void pressEnter() throws Exception
  • As we know stop input when it encounter newline
  • i have make getChar function which is taking input from user and sure newline using pressEnter function
  • pressEnter is use to ensure newline character using while loop
  • loop stop when user press enter otherwise it looking in stream for new line

Wednesday, 4 July 2012

Add Controls Run time in VB.NET & C#

Mostly we make control design time, we handle many event like click, mouseover,moueout etc. This is a easy process for design time because there is not any need to attach event handler visual studio attach necessary code automatically.
You can add control on run time………… for do this you will have to perform following steps
  • Make an object of relevant control
    eg. Button btn =new Button()      [C# ]
          dim btn as new Button()         [VB.NET]
  • After make an object of control you have to manage control property
    eg. Location,size,backcolor,text etc
  • You can also attach events..
Add an Button in C#
  Button btn = new Button();
            btn.Location=new Point(100,100);
            btn.Click +=new EventHandler(btn_Click);
     following function will catch and handle button click event….
private void btn_Click(object sender,EventArgs e)
Add a combo box in
            Dim com As ComboBox
        com = New ComboBox
        com.Location = New Point(150, 100)
        AddHandler com.SelectedIndexChanged,AddressOf com_click
following function will catch and handle combo box
selectindexchange event….
       Private Sub com_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MsgBox("Called event")
    End Sub

Monday, 2 July 2012

How to Retrieve records from ms access using date field in condition

Hi...... there
As you know SQL is a language which enable us to use database. If you've knowledge of SQL then you can operate any database software, for achieve this you just need to know how to run SQL Statement in that DBMS package
One thing you must know that there are some different in SQL in different DBMS package they use different data type and size, they treat date field as different way so if you want to use SQL you must know what are the SQL specification for that DBMS package
Develop Raj Kumar
Form of project
  • MS Access treat date field differently from SQL server
  • If you want to make a condition based on date you'll have to put date between ## e.g #7/28/2010
  • Import System.Data.OleDb name space for oledb class




    Save Button Code

    Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=your path")
                Dim dd As String
                dd = DateTimePicker1.Value.Date
                Dim com As New OleDbCommand()
                com.Connection = con
                com.CommandText = "insert into stu values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & dd & "')"
            Catch ex As Exception
            End Try

    Search Button Code

     Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your Path")
            Dim da As New OleDbDataAdapter("select * from stu where dob=#" & DateTimePicker1.Value.Date & "#", con)
            Dim ds As New DataSet
            DataGridView1.DataSource = ds.Tables(0)