Excel数据导入的问题~又是isam...
protected void btnOK_Click(object sender, EventArgs e)
{
string sPath = Server.MapPath( "~/UploadFiles/ ");
FileManager FileMng = new FileManager(); // 自定义的FileManager类
if (FileMng.Upload(FileUpload1, sPath) == " ") // 如果上传成功
{
string sFile = sPath + FileUpload1.FileName;
string sCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + sFile + ";Extended Properties= 'Excel 8.0;HDR=YES;IMEX=1 '; "; //IMEX=1 用来转换文本
OleDbConnection OleCon = new OleDbConnection(sCon);
OleDbDataAdapter OleDAp = new OleDbDataAdapter( "SELECT * FROM [Sheet1$] ", OleCon);
DataSet ds = new DataSet();
OleDAp.Fill(ds, "[Sheet1$] "); // 找不到可安装的 ISAM。!!!
int iCityID;
string sCityNam, sCityLevel,sSQL;
foreach (DataRow dr in ds.Tables[0].Rows)
{
iCityID=int.Parse( dr[ "CityID "].ToString());
sCityNam = dr[ "CityNam "].ToString();
sCityLevel = dr[ "CityLevel "].ToString();
sSQL = "insert into city(CityID,CityNam,CityLevel) values( "+iCityID+ ", ' "+sCityNam+ " ', ' "+sCityLevel+ " ') ";
try
&nbs