Sunday, 17 December 2017

how to insert value in table using sql server

how to insert value in table using sql server

insert into students(id,name,course) values (9,'bilal','BSE')

How to create a table in sql server

How to create a table in sql server

 create table students
(
      stdID int primary key,
    Name nvarchar(30),
    Course nvarchar(30)
)

how to create a database in sql server

How to create a database in sql server

create database college

after this you write

use college


      
 

A program find the table of number

import java.awt.Toolkit;

import java.util.Calendar;

import java.util.GregorianCalendar;

import java.util.logging.Level;

import java.util.logging.Logger;

import javax.swing.JOptionPane;

import java.io.*;

import com.sun.speech.freetts.*;


public class tabels extends javax.swing.JFrame {


    /**

     * Creates new form tabels

     */

    public tabels() {

        initComponents();

     }


     

    /**

     * This method is called from within the constructor to initialize the form.

     * WARNING: Do NOT modify this code. The content of this method is always

     * regenerated by the Form Editor.

     */

    @SuppressWarnings("unchecked")

    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          

    private void initComponents() {


        jPanel1 = new javax.swing.JPanel();

        tf1 = new javax.swing.JTextField();

        jLabel2 = new javax.swing.JLabel();

        tf = new javax.swing.JTextField();

        jLabel3 = new javax.swing.JLabel();

        jButton1 = new javax.swing.JButton();

        jButton2 = new javax.swing.JButton();

        jScrollPane1 = new javax.swing.JScrollPane();

        ta = new javax.swing.JTextArea();

        l = new javax.swing.JLabel();


        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);


        tf1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

        tf1.addKeyListener(new java.awt.event.KeyAdapter() {

            public void keyTyped(java.awt.event.KeyEvent evt) {

                tf1KeyTyped(evt);

            }

        });


        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

        jLabel2.setForeground(new java.awt.Color(102, 102, 0));

        jLabel2.setText("Enter table number");

        jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {

                jLabel2MouseClicked(evt);

            }

        });


        tf.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

        tf.addKeyListener(new java.awt.event.KeyAdapter() {

            public void keyTyped(java.awt.event.KeyEvent evt) {

                tfKeyTyped(evt);

            }

        });


        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

        jLabel3.setForeground(new java.awt.Color(102, 102, 0));

        jLabel3.setText("Enter table Limit");

        jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {

                jLabel3MouseClicked(evt);

            }

        });


        jButton1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N

        jButton1.setForeground(new java.awt.Color(102, 102, 0));

        jButton1.setText("Display Table");

        jButton1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jButton1ActionPerformed(evt);

            }

        });


        jButton2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N

        jButton2.setForeground(new java.awt.Color(102, 102, 0));

        jButton2.setText("Refresh");

        jButton2.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jButton2ActionPerformed(evt);

            }

        });


        ta.setColumns(20);

        ta.setFont(new java.awt.Font("Monospaced", 1, 24)); // NOI18N

        ta.setForeground(new java.awt.Color(102, 102, 0));

        ta.setRows(5);

        jScrollPane1.setViewportView(ta);


        l.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N

        l.setText("Table of Number");


        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

        jPanel1.setLayout(jPanel1Layout);

        jPanel1Layout.setHorizontalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

                .addGap(0, 0, Short.MAX_VALUE)

                .addComponent(l, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addGap(144, 144, 144))

            .addGroup(jPanel1Layout.createSequentialGroup()

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addGap(30, 30, 30)

                        .addComponent(jButton2)

                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                        .addComponent(jButton1))

                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 411, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addContainerGap()

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addComponent(jLabel2)

                                .addGap(18, 18, 18)

                                .addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addComponent(jLabel3)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                .addComponent(tf, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)))))

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );

        jPanel1Layout.setVerticalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel1Layout.createSequentialGroup()

                .addGap(40, 40, 40)

                .addComponent(l)

                .addGap(18, 18, 18)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jLabel2))

                .addGap(28, 28, 28)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                    .addComponent(tf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jLabel3))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jButton1)

                    .addComponent(jButton2))

                .addGap(18, 18, 18)

                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE))

        );


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

        getContentPane().setLayout(layout);

        layout.setHorizontalGroup(

            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

        );

        layout.setVerticalGroup(

            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                .addContainerGap())

        );


        pack();

    }// </editor-fold>                        


    private void tfKeyTyped(java.awt.event.KeyEvent evt) {                            

 char ch = evt.getKeyChar();

     if(Character.isAlphabetic(ch))

     { 

         evt.consume();

     } // TODO add your handling code here:

    }                           


    private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {                                     

// TODO add your handling code here:

    }                                    


    private void tf1KeyTyped(java.awt.event.KeyEvent evt) {                             

        // TODO add your handling code here:

    }                            


    private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {                                     

        // TODO add your handling code here:

    }                                    


    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

                  try {

         

            int n1=Integer.parseInt(tf.getText());

            int n=Integer.parseInt(tf1.getText());

         for(int i=1;i<=n1;i++){

       ta.append(n+"   x    "+i+"  =  "+n*i+"\n");

 

      

     

     }  }

catch(Exception e)

{

    JOptionPane.showMessageDialog(null, e);

}        // TODO add your handling code here:

    }                                        


    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         

     ta.setText("");

     tf1.setText("");

        tf.setText("");// TODO add your handling code here:

    }                                        


    /**

     * @param args the command line arguments

     */

    public static void main(String args[]) {

        /* Set the Nimbus look and feel */

        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 

         */

        try {

            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {

                if ("Nimbus".equals(info.getName())) {

                    javax.swing.UIManager.setLookAndFeel(info.getClassName());

                    break;

                }

            }

        } catch (ClassNotFoundException ex) {

            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (InstantiationException ex) {

            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (IllegalAccessException ex) {

            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (javax.swing.UnsupportedLookAndFeelException ex) {

            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        }

        //</editor-fold>


        /* Create and display the form */

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                new tabels().setVisible(true);

            }

        });

    }


    // Variables declaration - do not modify                     

    private javax.swing.JButton jButton1;

    private javax.swing.JButton jButton2;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel3;

    private javax.swing.JPanel jPanel1;

    private javax.swing.JScrollPane jScrollPane1;

    private javax.swing.JLabel l;

    private javax.swing.JTextArea ta;

    private javax.swing.JTextField tf;

    private javax.swing.JTextField tf1;

    // End of variables declaration                   

}

java program print the number of table

import java.awt.Toolkit;import java.util.Calendar;import java.util.GregorianCalendar;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;import java.io.*;import com.sun.speech.freetts.*;
public class tabels extends javax.swing.JFrame {
    /**     * Creates new form tabels     */    public tabels() {        initComponents();     }
         /**     * This method is called from within the constructor to initialize the form.     * WARNING: Do NOT modify this code. The content of this method is always     * regenerated by the Form Editor.     */    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">                              private void initComponents() {
        jPanel1 = new javax.swing.JPanel();        tf1 = new javax.swing.JTextField();        jLabel2 = new javax.swing.JLabel();        tf = new javax.swing.JTextField();        jLabel3 = new javax.swing.JLabel();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        jScrollPane1 = new javax.swing.JScrollPane();        ta = new javax.swing.JTextArea();        l = new javax.swing.JLabel();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        tf1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N        tf1.addKeyListener(new java.awt.event.KeyAdapter() {            public void keyTyped(java.awt.event.KeyEvent evt) {                tf1KeyTyped(evt);            }        });
        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N        jLabel2.setForeground(new java.awt.Color(102, 102, 0));        jLabel2.setText("Enter table number");        jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {            public void mouseClicked(java.awt.event.MouseEvent evt) {                jLabel2MouseClicked(evt);            }        });
        tf.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N        tf.addKeyListener(new java.awt.event.KeyAdapter() {            public void keyTyped(java.awt.event.KeyEvent evt) {                tfKeyTyped(evt);            }        });
        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N        jLabel3.setForeground(new java.awt.Color(102, 102, 0));        jLabel3.setText("Enter table Limit");        jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {            public void mouseClicked(java.awt.event.MouseEvent evt) {                jLabel3MouseClicked(evt);            }        });
        jButton1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N        jButton1.setForeground(new java.awt.Color(102, 102, 0));        jButton1.setText("Display Table");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });
        jButton2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N        jButton2.setForeground(new java.awt.Color(102, 102, 0));        jButton2.setText("Refresh");        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        });
        ta.setColumns(20);        ta.setFont(new java.awt.Font("Monospaced", 1, 24)); // NOI18N        ta.setForeground(new java.awt.Color(102, 102, 0));        ta.setRows(5);        jScrollPane1.setViewportView(ta);
        l.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N        l.setText("Table of Number");
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()                .addGap(0, 0, Short.MAX_VALUE)                .addComponent(l, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(144, 144, 144))            .addGroup(jPanel1Layout.createSequentialGroup()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addGap(30, 30, 30)                        .addComponent(jButton2)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jButton1))                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 411, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addContainerGap()                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)                            .addGroup(jPanel1Layout.createSequentialGroup()                                .addComponent(jLabel2)                                .addGap(18, 18, 18)                                .addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE))                            .addGroup(jPanel1Layout.createSequentialGroup()                                .addComponent(jLabel3)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                .addComponent(tf, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)))))                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addGap(40, 40, 40)                .addComponent(l)                .addGap(18, 18, 18)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jLabel2))                .addGap(28, 28, 28)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addComponent(tf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jLabel3))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jButton1)                    .addComponent(jButton2))                .addGap(18, 18, 18)                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE))        );
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                .addContainerGap())        );
        pack();    }// </editor-fold>                        
    private void tfKeyTyped(java.awt.event.KeyEvent evt) {                             char ch = evt.getKeyChar();     if(Character.isAlphabetic(ch))     {          evt.consume();     } // TODO add your handling code here:    }                           
    private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {                                     // TODO add your handling code here:    }                                    
    private void tf1KeyTyped(java.awt.event.KeyEvent evt) {                                     // TODO add your handling code here:    }                            
    private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {                                             // TODO add your handling code here:    }                                    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                           try {                     int n1=Integer.parseInt(tf.getText());            int n=Integer.parseInt(tf1.getText());         for(int i=1;i<=n1;i++){       ta.append(n+"   x    "+i+"  =  "+n*i+"\n");                 }  }catch(Exception e){    JOptionPane.showMessageDialog(null, e);}        // TODO add your handling code here:    }                                        
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                              ta.setText("");     tf1.setText("");        tf.setText("");// TODO add your handling code here:    }                                        
    /**     * @param args the command line arguments     */    public static void main(String args[]) {        /* Set the Nimbus look and feel */        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html          */        try {            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {                if ("Nimbus".equals(info.getName())) {                    javax.swing.UIManager.setLookAndFeel(info.getClassName());                    break;                }            }        } catch (ClassNotFoundException ex) {            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        } catch (InstantiationException ex) {            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        } catch (IllegalAccessException ex) {            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        } catch (javax.swing.UnsupportedLookAndFeelException ex) {            java.util.logging.Logger.getLogger(tabels.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        }        //</editor-fold>
        /* Create and display the form */        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new tabels().setVisible(true);            }        });    }
    // Variables declaration - do not modify                         private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JPanel jPanel1;    private javax.swing.JScrollPane jScrollPane1;    private javax.swing.JLabel l;    private javax.swing.JTextArea ta;    private javax.swing.JTextField tf;    private javax.swing.JTextField tf1;    // End of variables declaration                   }