Skip to content

Instantly share code, notes, and snippets.

@HammadMaqbool
Created March 30, 2016 11:46
Show Gist options
  • Save HammadMaqbool/000520c4227b383140e8ee1be3a088be to your computer and use it in GitHub Desktop.
Save HammadMaqbool/000520c4227b383140e8ee1be3a088be to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
namespace Connection_Class
{
public class Connection_Query
{
string ConnectionString = "";
SqlConnection con;
public void OpenConection()
{
con = new SqlConnection(ConnectionString);
con.Open();
}
public void CloseConnection()
{
con.Close();
}
public void ExecuteQueries(string Query_)
{
SqlCommand cmd = new SqlCommand(Query_,con);
cmd.ExecuteNonQuery();
}
public SqlDataReader DataReader(string Query_)
{
SqlCommand cmd = new SqlCommand(Query_,con);
SqlDataReader dr = cmd.ExecuteReader();
return dr;
}
public object ShowDataInGridView(string Query_)
{
SqlDataAdapter dr = new SqlDataAdapter(Query_, ConnectionString);
DataSet ds = new DataSet();
dr.Fill(ds);
object dataum = ds.Tables[0];
return dataum;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment