using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; using System.Configuration; namespace Ecommersee.DataLayer { public class DataAccess { public static string ConnectionString { get { return ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString.ToString(); } } public static SqlParameter AddParameter(string parameterName, object value, SqlDbType DbType, int size) { SqlParameter param = new SqlParameter(); param.ParameterName = parameterName; param.Value = value.ToString(); param.SqlDbType = DbType; param.Size = size; param.Direction = ParameterDirection.Input; return param; } public static DataTable ExecuteDTByProcedure(string Name, SqlParameter[] Params) { SqlConnection conn = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = Name; cmd.Parameters.AddRange(Params); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter adopter = new SqlDataAdapter(cmd); DataTable dTable = new DataTable(); try { adopter.Fill(dTable); } catch(Exception ex) { } finally { adopter.Dispose(); cmd.Parameters.Clear(); cmd.Dispose(); conn.Dispose(); } return dTable; } } }
Data Source
Source
Sourse
Data Source=servername\instancename;Integrated Security=...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)