SLR Db Connector

SLR DB Connector Free Download

SLR DB Connector Download: C# Ui Academy presents SLR Db Connector Library on its initial 1.0 version. SLR Db Connector is library specially designed for beginners and intermediate level developers of C#. Using this library, user can communicate with the SQL Server Database without having to write any extra code to perform your desired operation like Create, Read, Update, Delete. In this short tutorial, we’ll discuss about functionalities of SLR Db Connector library.

To access all the methods of SLR Db Library, you just have to add the SLRDbConnector DLL file into the references of your project. Go to the solution explorer, Right click on project References -> Add References->Browse: select the DLL file from choose file dialog window and click OK button.

Configuring App.Config:

Go to your app.config file and declare a connection string between <configuration></configuration> tags like:

        <add name="ConnString"
            connectionString="Data Source=DESKTOP-CFLOBRQ\SQLEXPRESS;Initial Catalog=ContractDb; Integrated Security=True; providerName="System.Data.SqlClient" />

Please Don’t Forget to add the name of connection string to exact “ConnString” otherwise the SLR Db Connector will not recognise your connection string.

Creating an Object of DbConnector:

To perform any database operation, declare an object of DbConnector Class on right above the constructor like:

DbConnector db = new DbConnector();

Get Single Value from Database:

SLR Db Connector has an inbuilt method to get a single value using a column index. To get a single value from database, just pass a Query Text, an out variable and index in parameters of GetSingleValue method. for example:

db.getSingleValue(“select id from tblUsers where username = ‘”+txtUserName.Text+”‘”,out userName,0);

In this method, The first parameter would be the query string, the second parameter will be the variable in which the returned value will saved. Third parameter will be the index of column.

Above line will return the ID from tblUsers and save it in the userName variable which is the second parameter of the method.

We can use index parameter to access different values from query.If we have selected multiple attributes from the table. for example:

lets pass a query which will select 3 columns from the table. like:

select id,name,email from tblUsers where username = ‘”+txtUserName.Text+”‘

Now if we want to access the name attribute, we must have to pass the parameter value 1, as the name is in index 1. Similarly, if we want to access email, we must have to pass the parameter value 2.

Perform CRUD:

Performing CRUD (Create Read Update Delete) using SLR Db Connector is really easy. Just pass your query as a parameter to perform your desired operation. for example:

db.performCRUD("create table tblUsers(id int, name varchar(50),password nvarchar(50))");
//This will create a table named tblUsers

db.performCRUD("delete from tblUsers where id = '"+userId+"'");
//This will delete records from tblUsers

db.performCRUD("update tblUsers set name = '"+txtName.Text+"' where id = '"+userId+"'");
//This will update the name value

db.performCRUD("insert into tblUsers(name,password) values('"+txtName.Text+"','"+txtPassword.Text+"')");
//This will insert value to the database

Fill Data Grid View:

Filling the data gridview using SLR DbConnector is so easy. just pass your query and the name of your Data gridview in the parameters of fillDataGridView method.

Get the values from database and display those values in Data Gridview like:

db.fillDataGridView("select * from tblUsers",datagridview1);
//datagridview1 is the name of the data grid view.

The above line will get the all records from table and display it in the data grid view.

Fill Combobox:

To fill the combobox with the values from database, just pass you query and name of combobox in the parameters of FillCombobox method. for example:

db.FillCombobox(“select name from tblRoles”,combobox1);
//combobox1 is the name of combobox.

The above line of code will fetch all names of roles from database and fill the combobox with those names.

Get an Array of Values:

SLR Db Connector also supports get multiple values from database. just pass your query and length of the array in parameter of getArray() method. for example:

string[] userDetails = db.getArray(“select name,fatherName,cellnumber from tblUsers where username = ‘”+txtUsername.Text+”‘”,3);
//The first parameter is query and the second parameter is the number of attributes which are selected using query.

The Above line will get all 3 values from database and save them in userDetails array. now you can access those value using the index of this array like:

lblFullName.Text = userDetails[0];
lblFatherName = userDetails[1];
lblCellNo = userDetails[2];


SLR DB Connector Download for free

4 Replies to “SLR DB Connector Free Download”

    1. Hi Maxdev, This is the first version of SLRDbConnector. Initially it supports only MS SQL Server.
      Next Version will support MySQL, PgSQL and Oracle also.. 🙂

  1. Can you make a video of it?

  2. I really like your writing style, great information, thankyou for posting : D.

Comments are closed.