How to Convert table value to excel or ini file

Hi,

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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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.
0
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..?
0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
do you mean to load Excel data into MS SQL?
0
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)
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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?
0
Ganesh STech Lead cum developerAuthor Commented:
yes. exactly..
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you can do that using LinqToExcel:

https://www.nuget.org/packages/LinqToExcel

and example is available here:

C#: Query Excel and .CSV Files Using LinqToExcel
https://www.codeproject.com/Articles/659643/Csharp-Query-Excel-and-CSV-Files-Using-LinqToExcel

see if these helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ganesh STech Lead cum developerAuthor Commented:
thanks.it's working.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.