Tuesday, May 1, 2012

Deleting and updating records using ASP

                         Deleting and updating records using ASP 

Here is a simple asp code for updating or deleting records from a MS Access database.


for del.asp:
<%
Dim f,l,c,e,co,sql,Rs
f= Request.Form("fn")
Dim objConn
set objConn=Server.CreateObject("ADODB.Connection")
objConn.Connectionstring="PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\ip\feedback.mdb"
Set Rs = Server.CreateObject("ADODB.Recordset")
objConn.Open
sql= "Delete * from [sugest] where fname='"&f&"'"
set Rs=objConn.Execute(sql)
objConn.close()
set objConn=nothing
Response.write("Deleted successfully!")
%>

for update.asp:

<%
Dim f,l,c,e,co,sql,Rs
f= Request.Form("fn")
Dim objConn
set objConn=Server.CreateObject("ADODB.Connection")
objConn.Connectionstring="PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\ip\feedback.mdb"
Set Rs = Server.CreateObject("ADODB.Recordset")
objConn.Open
sql= "Update [sugest] set fname='shona' where fname='"&f&"'"
set Rs=objConn.Execute(sql)
objConn.close()
set objConn=nothing
%>
Dont forget to create a form to accept the name to be updated or deleted from records.for eg:
 form.asp:
<html>
<head>
</head>
<body>
<form method=post action="update.asp">
<input type=text name="fn">
<input type=submit value=Update  >
</form>
</body>
</html>
similarly prepare a form for del.asp.

Database Connectivity using ASP

                                         Database Connectivity using  ASP 

Using ASP we can establish a database connection using the following code:

Dim objConn
set objConn=Server.CreateObject("ADODB.Connection")
objConn.Connectionstring="PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\ip\feedback.mdb"
objConn.Open 

NOTE:here the database is created in MS Access 2000-2003 format.

For adding records to the database,try the following code:

<html>
<body>
<%
Dim f,l,c,e,co,sql
'Getting information from the submitted form
f= Request.Form("fn")
l=Request.Form("ln")
c=Request.Form("cno")
e= Request.Form("email")
co=Request.Form("com")
Dim objConn
set objConn=Server.CreateObject("ADODB.Connection")
objConn.Connectionstring="PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\ip\feedback.mdb"
objConn.Open
sql = "INSERT INTO [sugest] ([fname],[lname],"
sql = sql & "[contactno],[email-id],[comment])"
sql = sql & " VALUES "
sql = sql & "('" & f & "',"
sql = sql & "'" & l & "',"
sql = sql & "'" & c & "',"
sql = sql & "'" & e & "',"
sql = sql & "'" & co & "')"
objConn.Execute sql
objConn.close
response.write("THANK YOU !")
%>

</body>
</html>  

Hope..this may help you!!

Saturday, April 28, 2012

Just go for it!!: Primitive chat program using XMLRPC

Just go for it!!: Primitive chat program using XMLRPC:  Primitive chat program using XMLRPC! try this!! This is a program in java to illustrate XMLRPC ...so copy this code..compile and run it...

Primitive chat program using XMLRPC

 Primitive chat program using XMLRPC! try this!!

This is a program in java to illustrate XMLRPC ...so copy this code..compile and run it!its fun!!

 

Code for PrimitiveChat.java :

import javax.swing.*;

public class PrimitiveChat {

public String printText(String str) {
    System.out.println( "Received: "+str);
    return "ok";
    }

 public static void main (String [] args) {
  String input;
  PrimitiveChat pc = new PrimitiveChat();

  do {
    input = JOptionPane.showInputDialog("Enter your message");
    if( input != null ) {
        pc.printText(input); // a local procedure call.
        }
    } while ( input != null );
  System.exit(0);
  }
}

OUTPUT:


Just go for it!!: RSA code in Java

Just go for it!!: RSA code in Java:       To encrypt and decrypt a string using RSA algorithm The following code helps the user to provide a string for encryption and decry...

RSA code in Java

      To encrypt and decrypt a string using RSA algorithm

The following code helps the user to provide a string for encryption and decryption using RSA algorithm with the help of Big Integer in java.

Source code for RSA.java:

import java.math.BigInteger; 
import java.util.Random;
import java.io.*;
 
 
public class RSA { 
     
    private BigInteger p; 
    private BigInteger q; 
    private BigInteger N; 
    private BigInteger phi; 
    private BigInteger e; 
    private BigInteger d; 
    private int bitlength = 1024; 
    private int blocksize = 256; //blocksize in byte 
     
    private Random r; 
     public RSA() { 
        r = new Random(); 
        p = BigInteger.probablePrime(bitlength, r); 
        q = BigInteger.probablePrime(bitlength, r); 
          N = p.multiply(q); 
           
        phi = p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE)); 
          e = BigInteger.probablePrime(bitlength/2, r); 
         
        while (phi.gcd(e).compareTo(BigInteger.ONE) > 0 && e.compareTo(phi) < 0 ) { 
            e.add(BigInteger.ONE); 
        } 
 d = e.modInverse(phi);  
    } 
     
    public RSA(BigInteger e, BigInteger d, BigInteger N) { 
        this.e = e; 
        this.d = d; 
        this.N = N; 
    } 
     
    public static void main (String[] args) throws IOException

        RSA rsa = new RSA(); 
           DataInputStream in=new DataInputStream(System.in);  
        String teststring ;
         System.out.println("Enter the plain text:");
        teststring=in.readLine();
        System.out.println("Encrypting String: " + teststring); 
        System.out.println("String in Bytes: " + bytesToString(teststring.getBytes())); 
 
        // encrypt 
        byte[] encrypted = rsa.encrypt(teststring.getBytes());                   
        System.out.println("Encrypted String in Bytes: " + bytesToString(encrypted)); 
         
        // decrypt 
        byte[] decrypted = rsa.decrypt(encrypted);       
        System.out.println("Decrypted String in Bytes: " +  bytesToString(decrypted)); 
         
        System.out.println("Decrypted String: " + new String(decrypted)); 
         
    } 
 
   private static String bytesToString(byte[] encrypted) { 
        String test = ""; 
        for (byte b : encrypted) { 
            test += Byte.toString(b); 
        } 
        return test; 
    } 
     
     public byte[] encrypt(byte[] message) {      
        return (new BigInteger(message)).modPow(e, N).toByteArray(); 
    } 
       
    public byte[] decrypt(byte[] message) { 
        return (new BigInteger(message)).modPow(d, N).toByteArray(); 
    } 
     
}

OUTPUT:

Tuesday, April 3, 2012

Just go for it!!: Remove hyperlinks from a word file at a time!

Just go for it!!: Remove hyperlinks from a word file at a time!:                                                           TRY THIS!! Sometimes what we hate to do the most becomes a reason for the c...