"Select distinct departmentname from Department"
The Department name should show in the drop down list and I should be able to select one department name from the list.
This is my code for read the column name from an excet test11.xls.now i want to fetch the dataset to that column name departmant.
please help.
Expand|Select|Wrap|Line Numbers
- string filePath1 = Server.MapPath("test11.xls");
- da = new SqlDataAdapter ("select departmentname from departmentmaster", con);
- ds = new DataSet();
- da.Fill(ds);
- DataTable columns;
- string[] restrictions = { null, null, "Data$", null };
- //string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
- string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath1 + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1;\"";using (OleDbConnection connection = new OleDbConnection(connectionString))
- {
- connection.Open();
- columns = connection.GetSchema("Columns", restrictions);
- String[] excelSheets = new String[columns.Rows.Count];
- int iwork = 0;
- // Add the sheet name to the string array.
- foreach (DataRow row in columns.Rows)
- {
- excelSheets[iwork] = row["Column_NAME"].ToString();if (excelSheets[iwork] == "Department")
- {
- // Here how can i fetch that dataset to the column Department
- }
- iwork++;
- }
- }