Link to home
Start Free TrialLog in
Avatar of Gani tpt
Gani tpt

asked on

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..?
Avatar of Dirk Strauss
Dirk Strauss
Flag of South Africa image

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.
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.
Avatar of Gani tpt
Gani tpt

ASKER

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..?
do you mean to load Excel data into MS SQL?
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)
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?
yes. exactly..
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks.it's working.