Hi
You can use from bellow class for manage that.
-----------------------------------------------------------------------------------
public class DBManagement
{
public SqlConnection OpenConnection()
{
string connectionString = "Data Source = [YourServerName]; Initial Catalog = [YourDatabaseName]; User ID = [YourSqlUserName]; Password = [YourSqlUserPassword]";
SqlConnection connection = null;
try
{
connection = new SqlConnection(connectionString);
connection.Open();
}
catch
{
Console.WriteLine("DataBase is not reachable....");
}
return connection;
}
public DataTable Execute(string queryString)
{
SqlConnection connection = OpenConnection();
SqlCommand query = new SqlCommand(queryString, connection);
DataTable resultTable = new DataTable();
SqlDataAdapter adopter = new SqlDataAdapter(query);
adopter.Fill(resultTable);
connection.Close();
return resultTable;
}
}
-----------------------------------------------------------------------------------
You can send [youparameter] directly to your methods of this class.
I hope it's helpful.