How to Convert table value to excel or ini file


currently i am using SQL Server table in one of my application.

But, my client asking me to change the table to excel file or ini file which is located in server path.

the reason is to change to excel or ini file is, my client doesn't have access to change the name of the value in table.

For example,

Table structure is below.

EmpNo      Sub1      Sub2      Sub3      Sub4
1      100      200      400      500
2      200      300      400      500
3      400      500      300      400
instead of the above table client's want to maintain in excel which need to be read from the folder.

see my sql code.

SqlCommand cmd = new SqlCommand(@"select Sub1,Sub2,Sub3 where Empno=@EmpNo", sqlcon);
                    cmd.Parameters.Add("@EmpNo", SqlDbType.NVarChar).Value = cmbEmp.SelectedItem.ToString();

 the same i want to convert and read from excel or ini.

How to change..?
Ganesh STech Lead cum developerAsked:
Who is Participating?
Ryan ChongConnect With a Mentor Commented:
you can do that using LinqToExcel:

and example is available here:

C#: Query Excel and .CSV Files Using LinqToExcel

see if these helps
Dirk StraussSenior Full Stack DeveloperCommented:
Will connecting the data table to Excel be an option? I'm assuming SQL Server. Connect a SQL Server database to your workbook (Power Query). Also look at Creating Microsoft Excel Connections to SQL databases. Lastly, see How-To Synchronize Data Between Excel and SQL Server.
Ryan ChongCommented:
if your client is insisting, for .NET applications, you can try define your settings in a .config or .xml file, and try to avoid plain .ini file.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Ganesh STech Lead cum developerAuthor Commented:
Thanks for your help.

My requirement is simple. client doesn't have access to modify anything in SQL Table if anything update in the table.

For that purpose, simply the same table structure want to use in excel and put it in corresponding server folder.

so finally they should read from the excel always..?
Ryan ChongCommented:
do you mean to load Excel data into MS SQL?
Ganesh STech Lead cum developerAuthor Commented:
no..just create a table like below format and put it some other folder.

EmpNo      Sub1      Sub2      Sub3      Sub4
1      100      200      400      500
2      200      300      400      500
3      400      500      300      400

read from the excel file in sheet 1 with the same table structure.

for query we may use LINQ with this datatable (datatable is excel)....

from the folder they should read either LINQ with datatable (datatable is excel)
Ryan ChongCommented:
ok, finally seems to get what you mean by "table". so you would like to change your data source from MS SQL database to Excel, am i right to say so?
Ganesh STech Lead cum developerAuthor Commented:
yes. exactly..
Ganesh STech Lead cum developerAuthor Commented:'s working.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.