//sql connections
/// Returns the results of a SQL Query in the form of a DataTable
public static DataTable SQLSelect(SqlCommand cmdSQLQuery)
{
//Get connection string
//string conConnectionString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
string conConnectionString=null;
SqlConnection SQLDatabaseConnection = new SqlConnection(conConnectionString);
//Perform Command
cmdSQLQuery.Connection = SQLDatabaseConnection;
DataSet dsPageInfo = new DataSet();
SqlDataAdapter daPageInfo = new SqlDataAdapter(cmdSQLQuery);
SQLDatabaseConnection.Open();
daPageInfo.Fill(dsPageInfo);
SQLDatabaseConnection.Close();
return dsPageInfo.Tables[0];
}
/// Executes a SQL Command
public static void ExecuteSQLCommand(SqlCommand CommandToExecute)
{
//get connection sring
SqlConnection SQLDatabaseConnection = new SqlConnection(conConnectionString);
//execute command
CommandToExecute.Connection = SQLDatabaseConnection;
SQLDatabaseConnection.Open();
CommandToExecute.ExecuteNonQuery();
SQLDatabaseConnection.Close();
}
//ole db connection
/// Returns the results of a SQL Query in the form of a DataTable
public static DataTable SQLSelect(OleDbCommand cmdOleDbCommand)
{
OleDbConnection OleDbDatabaseConnection = new OleDbConnection(conConnectionString);
//Perform Command
cmdOleDbCommand.Connection = OleDbDatabaseConnection;
DataSet dsPageInfo = new DataSet();
OleDbDataAdapter daPageInfo = new OleDbDataAdapter(cmdOleDbCommand);
OleDbDatabaseConnection.Open();
daPageInfo.Fill(dsPageInfo);
OleDbDatabaseConnection.Close();
return dsPageInfo.Tables[0];
}
public static void ExecuteSQLCommand(OleDbCommand CommandToExecute)
{
OleDbConnection OleDbDatabaseConnection = new OleDbConnection(conConnectionString);
//execute command
CommandToExecute.Connection = OleDbDatabaseConnection;
OleDbDatabaseConnection.Open();
CommandToExecute.ExecuteNonQuery();
OleDbDatabaseConnection.Close();
}
/// Returns the results of a SQL Query in the form of a DataTable
public static DataTable SQLSelect(SqlCommand cmdSQLQuery)
{
//Get connection string
//string conConnectionString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
string conConnectionString=null;
SqlConnection SQLDatabaseConnection = new SqlConnection(conConnectionString);
//Perform Command
cmdSQLQuery.Connection = SQLDatabaseConnection;
DataSet dsPageInfo = new DataSet();
SqlDataAdapter daPageInfo = new SqlDataAdapter(cmdSQLQuery);
SQLDatabaseConnection.Open();
daPageInfo.Fill(dsPageInfo);
SQLDatabaseConnection.Close();
return dsPageInfo.Tables[0];
}
/// Executes a SQL Command
public static void ExecuteSQLCommand(SqlCommand CommandToExecute)
{
//get connection sring
SqlConnection SQLDatabaseConnection = new SqlConnection(conConnectionString);
//execute command
CommandToExecute.Connection = SQLDatabaseConnection;
SQLDatabaseConnection.Open();
CommandToExecute.ExecuteNonQuery();
SQLDatabaseConnection.Close();
}
//ole db connection
/// Returns the results of a SQL Query in the form of a DataTable
public static DataTable SQLSelect(OleDbCommand cmdOleDbCommand)
{
OleDbConnection OleDbDatabaseConnection = new OleDbConnection(conConnectionString);
//Perform Command
cmdOleDbCommand.Connection = OleDbDatabaseConnection;
DataSet dsPageInfo = new DataSet();
OleDbDataAdapter daPageInfo = new OleDbDataAdapter(cmdOleDbCommand);
OleDbDatabaseConnection.Open();
daPageInfo.Fill(dsPageInfo);
OleDbDatabaseConnection.Close();
return dsPageInfo.Tables[0];
}
public static void ExecuteSQLCommand(OleDbCommand CommandToExecute)
{
OleDbConnection OleDbDatabaseConnection = new OleDbConnection(conConnectionString);
//execute command
CommandToExecute.Connection = OleDbDatabaseConnection;
OleDbDatabaseConnection.Open();
CommandToExecute.ExecuteNonQuery();
OleDbDatabaseConnection.Close();
}
No comments:
Post a Comment