Jia

Jia

  • NA
  • 9
  • 19.7k

Write Java code to ASP.NET

Mar 24 2013 2:41 PM
Can anyone convert the given Java code to ASP.NET.I don't understand java but i have to make a same file as below coding in Java.What is Actually happening here in Java code m not able to understand but i m gn requirement to develop same file in ASP.NET

/**
 *
 */
package com.di.kmp.amar.dal;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author Administrator
 *
 */
public class MSAccessDatabase {

    private Connection con;
    //private final String dsnName = "master";

    /**
     *
     */
    public MSAccessDatabase() {
        try {
            // TODO Auto-generated constructor stub
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = null;

        } catch (ClassNotFoundException cnfex) {
            cnfex.getException();
        }
    }

    public void openConnection(String s) {
        try {
            con = DriverManager.getConnection("jdbc:odbc:" + s);
        } catch (SQLException sqlex) {
            sqlex.getNextException();
        }
    }
    public boolean executeDML(String sql) {
        try {
            Statement st = con.createStatement();
            st.executeUpdate(sql);
                       //st.execute(sql);
            return true;
        } catch (SQLException sqlex) {
            sqlex.printStackTrace();
            return false;
        }
    }
    public ResultSet executeSelect(String sql)
    {
        ResultSet rs=null;
        try {
            Statement st = con.createStatement();
            rs=st.executeQuery(sql);
            return rs;
        } catch (SQLException sqlex) {
            sqlex.getNextException();
            return rs;
        }
    }
   
    public void closeConnection() {
        try {
            con.close();
        } catch (SQLException sqlex) {
            sqlex.getNextException();
        }

    }

}