//web.config
<
configuration
>
中配置节点
< appSettings >
< add key ="SqlString" value ="uid=sa;PWD=sa;DATA SOURCE=(local);INITIAL CATALOG=chinasuntv" />
< add key ="ExcelStr" value ="Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" />
< add key ="DataBase" value ="/program/UploadFiles/Program.xls" ></ add >
</ appSettings >
< appSettings >
< add key ="SqlString" value ="uid=sa;PWD=sa;DATA SOURCE=(local);INITIAL CATALOG=chinasuntv" />
< add key ="ExcelStr" value ="Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" />
< add key ="DataBase" value ="/program/UploadFiles/Program.xls" ></ add >
</ appSettings >
1
protected
void
btnUpLoad_Click(
object
sender, EventArgs e)
2 { //若此处未加逻辑判断,如果excel文件不存在则程序将会报异常
3 if(System.IO.File.Exists(MapPath(DataBase)))
4
2 { //若此处未加逻辑判断,如果excel文件不存在则程序将会报异常
3 if(System.IO.File.Exists(MapPath(DataBase)))
4