/GPX.Server.Extension/GeoRSSClient/ConnectionManager.cs
C# | 56 lines | 48 code | 8 blank | 0 comment | 0 complexity | 9aaba3993b08d9dd333a498bb5bd508b MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Data;
-
- namespace GeoRSSClient
- {
- static class ConnectionManager
- {
- public static SqlConnection GetConnection(string connectionName)
- {
- try
- {
- string connectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
- return new SqlConnection(connectionString);
- }
- catch(Exception ex)
- {
- throw ex;
- }
- finally
- {
-
- }
- }
-
- public static DataTable RunQuery(SqlConnection connection, string sql)
- {
- try
- {
- connection.Open();
-
- SqlCommand brokerCommand = new SqlCommand(sql, connection);
- SqlDataAdapter brokerAdapter = new SqlDataAdapter();
- DataSet ds = new DataSet();
-
- brokerAdapter.SelectCommand = brokerCommand;
- brokerAdapter.Fill(ds);
-
- return ds.Tables[0];
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
-
- }
- }
-
- }
- }