Created
March 30, 2016 11:46
-
-
Save HammadMaqbool/000520c4227b383140e8ee1be3a088be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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