Wednesday, June 15, 2016

DBASE Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

///
/// Summary description for dbase
///
public class dbase
{
public dbase()
{
//
// TODO: Add constructor logic here
//
}
    public static DataSet select(string qu) {
        try
        {

            DataSet ds = new DataSet();
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
            SqlCommand cmd = new SqlCommand(qu, con);
            con.Open();
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            adp.Fill(ds);
            con.Close();
            return ds;
         
        }
        catch (Exception exp)
        {

            return null;
        }
    }
    public static int insert(string qu) {
        try
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
            SqlCommand cmd = new SqlCommand(qu, con);
            con.Open();
            int ans = cmd.ExecuteNonQuery();
            con.Close();
            return ans;
        }
        catch (Exception exp) {
            return -1;
        }
    }

}

No comments:

Post a Comment