Skip to content

Alfred188/DAL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

DAL

A lib to help in coding

this lib help to connect to sql server database in C#

How to use

public static string ConnectionStr = "ConStr"; // Your connection string gose here

Select:

DAL dal = new DAL();
string spCom = string.Empty;
DataTable dt = new DataTable();

spCom = "SELECT  [ID],[Name] from [Table] where [ID]=@ID";
dbm = new DatabaseModel();
dbm.ParametrName = "@ID";
dbm.Value = Id.Text;
dbList.Add(dbm);

int result = 0;
dt = dal.selectTable(spCom, out result);
if (result == (int)_EnumManager.DbState.success)
{
    //dt is filled with data
}

Insert, Update, Delete:

string stb = string.Empty ;
DAL dal = new DAL();
string spCom = string.Empty;
List<DatabaseModel> dbList = new List<DatabaseModel>();
DatabaseModel dbm;
        
spCom = "INSERT into [Table] ([Value1Col],[Value2Col],[Value3Col]) values" +
    " (@Value1,@Value2,@Value3)";
dbm = new DatabaseModel(){
ParametrName = "@Value1",
Value = "Var1"};
dbList.Add(dbm);
        
dbm = new DatabaseModel(){
ParametrName = "@Value2",
Value = "Var2"};
dbList.Add(dbm);
        
dbm = new DatabaseModel(){
ParametrName = "@Value3",
Value = "Var3"};
dbList.Add(dbm);
        

int result = dal.runCommand(spCom, dbList);
if (result == (int)_EnumManager.DbState.success)
{
    //Success
}
else
{
    //Failes
}

About

A lib to help me in codding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages