Articles in this section
Category / Section

How to create a sample to sync Excel file with database using XlsIO?

1 min read

An Excel file can be generated based on a selected value from database using XlsIO. The following steps illustrates to sync an Excel file with database.

Step 1: Create a database and load values of a specific field from the database to a dropdown on the web form.

Step 2: Select an ID from the provided drop down to download an excel file.

Step 3: Make some changes on the downloaded file. Then upload it using upload button.

Step 4: Now the changes are made in the database. It can be viewed in a grid after clicking the Upload Excel button.

Here is the code snippet to pull values from the database.

C#

            OleDbConnection oleDB = new OleDbConnection();
            oleDB.ConnectionString = string.Format(ConnectionString,            ResolveApplicationDataPath(DBFileName, false));
            OleDbCommand command = new OleDbCommand("SELECT CustomerID FROM Customers", oleDB);
            oleDB.Open();
            OleDbDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                string customerID = reader.GetString(0);
                DropDownCustomers.Items.Add(customerID);
            }
            DropDownCustomers.SelectedIndex = 1;
            reader.Close();
            oleDB.Close();
 

VB

            Dim oleDB As OleDbConnection = New OleDbConnection()
            oleDB.ConnectionString = String.Format(ConnectionString, ResolveApplicationDataPath(DBFileName, False))
            Dim command As OleDbCommand = New OleDbCommand("SELECT CustomerID FROM Customers", oleDB)
            oleDB.Open()
            Dim reader As OleDbDataReader = command.ExecuteReader()
            While reader.Read()
             Dim customerID As String = reader.GetString(0)
            DropDownCustomers.Items.Add(customerID)
            End While
            DropDownCustomers.SelectedIndex = 1
            reader.Close()
            oleDB.Close()

 

Figure 1: UI of the sample


You can also refer to the sample here. 

Note

A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below.

You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied