Cybercrux

Everything is achievable through technology

Simple DAL

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text;
using System.IO;
namespace kpt
{
public class Class1
{

//ConfigurationManager.ConnectionStrings[“GetConnectionString”].ToString();
public SqlConnection con = new SqlConnection(“server=NEWVISION-PC\\SQLEXPRESS ;Integrated Security= True;database=kpt;”);

public SqlCommand cmd = new SqlCommand();
public SqlDataAdapter ada = new SqlDataAdapter();
public DataTable dt = new DataTable();
public SqlDataReader dr;

public Class1()
{ }
public SqlConnection getcon()
{
if (con.State == ConnectionState.Open)
{
con.Close();

}
else
{
con.Open();

}
return con;
}

public DataTable gettable(string str)
{
dt = new DataTable();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = str;
ada.SelectCommand = cmd;
ada.Fill(dt);
return dt;
}

public string execquery(string str)
{
try
{
cmd.Connection = getcon();
cmd.CommandType = CommandType.Text;
cmd.CommandText = str;
cmd.ExecuteNonQuery();
cmd.Connection = getcon();
return “1″;

}
catch (Exception ex)
{
return ex.Message;
}
}
public string execproc(string str)
{
try
{
cmd.Connection = getcon();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = str;
cmd.ExecuteNonQuery();
cmd.Connection = getcon();
return “1″;

}
catch (Exception ex)
{
return ex.Message;
}
}
public SqlDataReader execreader(string str)
{

cmd.Connection = getcon();
cmd.CommandType = CommandType.Text;
cmd.CommandText = str;
dr = cmd.ExecuteReader();
return dr;
}
}

}

One thought on “Simple DAL

  1. This information is worth everyone’s attention. Where can I find out more? guild wars 2 gold http://www.mmogm.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s