using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Reflection;
namespace ProjectHistoryCollector.DataAccess
{
public class ConnectToData
{
//private const string ConnectString = "Data Source=EDNAWS_063\\SQLEXPRESS;Initial Catalog=sidata;Persist Security Info=True;User ID=vansi;Password=123456789";
public ConnectToData()
{ }
private const string ConnectString = "Data Source=EDNAWS_063\\SQLEXPRESS;Initial Catalog=sidata;Persist Security Info=True;User ID=vansi;Password=123456789";
public SqlConnection myConnection;
public void OpenConnection()
{
myConnection = new SqlConnection(GetDBConnectionString());
try
{
if (myConnection.State == ConnectionState.Closed)
myConnection.Open();
}
catch(Exception ee)
{
}
}
public string GetDBConnectionString()
{
return ConnectString;
}
DataSet ConvertDataReaderToDataSet(SqlDataReader reader)
{
DataSet objDataSet = new DataSet();
while (reader.NextResult())
{
objDataSet.Tables.Add(ConvertDataReaderToDataTable(reader));
}
reader.Close();
return objDataSet;
}
public DataTable ConvertDataReaderToDataTable(SqlDataReader reader)
{
DataTable objDataTable = new DataTable();
int intFieldCount = reader.FieldCount;
int intCounter;
for (intCounter = 0; intCounter <= intFieldCount - 1; intCounter++)
objDataTable.Columns.Add(reader.GetName(intCounter), reader.GetFieldType(intCounter));
objDataTable.BeginLoadData();
Object[] objValues = new object[intFieldCount];
while (reader.Read())
{
reader.GetValues(objValues);
objDataTable.LoadDataRow(objValues, true);
}
reader.Close();
objDataTable.EndLoadData();
return objDataTable;
}
//--------------------------------------------------
//private const string ConnectString = "Data Source=EDNAWS_063\\SQLEXPRESS;Initial Catalog=sidata;Persist Security Info=True;User ID=vansi;Password=123456789";
//SqlConnection conn = new SqlConnection(connString);
//public void Open()
//{
// try
// {
// conn.Open();
// }
// catch (Exception ex)
// {
// Console.WriteLine("Error: " + ex);
// }
//}
//public void Close()
//{
// try
// {
// conn.Close();
// }
// catch (Exception e)
// {
// Console.WriteLine("Error: " + e);
// }
//}
}
}