当前位置:编程学习 > C#/ASP.NET >>

读取Access报错 说目录名称无效 明明是对的

  配置文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <!--皮肤文件名称。-->
    <add key="SkinName" value="Page.ssk" />
    <!--火灾报警数据目录。-->
    <add key="AlrmAdds" value="E:\中石化\MAIN.mdb"/>
    <!--火灾报警实时数据库地址。-->
    <add key="AlrmFileName" value="E:\MAIN.mdb" />
    <!--数据读取频率-->
    <add key="Interval" value="10000" />
    <add key="IBMSConnString" value="SERVER=.;UID=sa;PWD=ibms;DataBase=IBMS_ZSH; Max Pool 

Size=100; Min Pool Size=8" providerName="System.Data.SqlClient" />
  </appSettings>
</configuration>
——————————————————
 DirectoryInfo alrm = new DirectoryInfo(AppSettings.GetValue(_cfgName, "AlrmAdds"));
                System.IO.FileInfo[] files = alrm.GetFiles("AlrmAdds");
                Array.Sort(files, new SortFile(SortOption.FileName));
                foreach (System.IO.FileInfo file in files) {
                    DataSet ds = new DataSet();
                    ds = RS.Common.FileOperate.XmlOper.GetDataSet(file.FullName, RS.Common.FileOperate.XmlOper.XmlType.File);
                    StringBuilder strSql = new StringBuilder();
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++) {
                        strSql.AppendLine("INSERT INTO [FireHistory]([EventNum],[AlarmType],[Type],[Address],[DeviceType],[DeviceMdl],[DevLabel],[Date],[Time],[RcvdDate],[RcvdTime],[Value],[Operator],[Note],[MsgTypeInEnglish]) VALUES('" + ds.Tables[0].Rows[i]["EventNum"] + "','" + ds.Tables[0].Rows[i]["AlarmType"] + "','" + ds.Tables[0].Rows[i]["Type"] + "','" + ds.Tables[0].Rows[i]["Address"] + "','" + ds.Tables[0].Rows[i]["DeviceType"] + "','" + ds.Tables[0].Rows[i]["DeviceMdl"] + "','" + ds.Tables[0].Rows[i]["DevLabel"] + "','" + ds.Tables[0].Rows[i]["Date"] + "','" + ds.Tables[0].Rows[i]["Time"] + "','" + ds.Tables[0].Rows[i]["RcvdDate"] + "','" + ds.Tables[0].Rows[i]["RcvdTime"] + "','" + ds.Tables[0].Rows[i]["Value"] + "','" + ds.Tables[0].Rows[i]["Operator"] + "','" + ds.Tables[0].Rows[i]["Note"] + "','" + ds.Tables[0].Rows[i]["MsgTypeInEnglish"] + "')");
                    }
                    RS.DBUtility.SqlHelper.ExecuteNonQuery(AppSettings.GetValue(_cfgName, "IBMSConnString"), CommandType.Text, strSql.ToString());
                }
--------------------编程问答--------------------
引用 楼主 cq1029063251 的回复:
  配置文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <!--皮肤文件名称。-->
    <add key="SkinName" value="Page.ssk" />
    <!--火灾报警数据目录。-->
    <add key="AlrmAdds" value="E:\中石化\MAIN.mdb"/>
    <!--火灾报警实时数据库地址。-->
    <add key="AlrmFileName" value="E:\MAIN.mdb" />
    <!--数据读取频率-->
    <add key="Interval" value="10000" />
    <add key="IBMSConnString" value="SERVER=.;UID=sa;PWD=ibms;DataBase=IBMS_ZSH; Max Pool 

Size=100; Min Pool Size=8" providerName="System.Data.SqlClient" />
  </appSettings>
</configuration>
——————————————————
 DirectoryInfo alrm = new DirectoryInfo(AppSettings.GetValue(_cfgName, "AlrmAdds"));
                System.IO.FileInfo[] files = alrm.GetFiles("AlrmAdds");
                Array.Sort(files, new SortFile(SortOption.FileName));
                foreach (System.IO.FileInfo file in files) {
                    DataSet ds = new DataSet();
                    ds = RS.Common.FileOperate.XmlOper.GetDataSet(file.FullName, RS.Common.FileOperate.XmlOper.XmlType.File);
                    StringBuilder strSql = new StringBuilder();
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++) {
                        strSql.AppendLine("INSERT INTO [FireHistory]([EventNum],[AlarmType],[Type],[Address],[DeviceType],[DeviceMdl],[DevLabel],[Date],[Time],[RcvdDate],[RcvdTime],[Value],[Operator],[Note],[MsgTypeInEnglish]) VALUES('" + ds.Tables[0].Rows[i]["EventNum"] + "','" + ds.Tables[0].Rows[i]["AlarmType"] + "','" + ds.Tables[0].Rows[i]["Type"] + "','" + ds.Tables[0].Rows[i]["Address"] + "','" + ds.Tables[0].Rows[i]["DeviceType"] + "','" + ds.Tables[0].Rows[i]["DeviceMdl"] + "','" + ds.Tables[0].Rows[i]["DevLabel"] + "','" + ds.Tables[0].Rows[i]["Date"] + "','" + ds.Tables[0].Rows[i]["Time"] + "','" + ds.Tables[0].Rows[i]["RcvdDate"] + "','" + ds.Tables[0].Rows[i]["RcvdTime"] + "','" + ds.Tables[0].Rows[i]["Value"] + "','" + ds.Tables[0].Rows[i]["Operator"] + "','" + ds.Tables[0].Rows[i]["Note"] + "','" + ds.Tables[0].Rows[i]["MsgTypeInEnglish"] + "')");
                    }
                    RS.DBUtility.SqlHelper.ExecuteNonQuery(AppSettings.GetValue(_cfgName, "IBMSConnString"), CommandType.Text, strSql.ToString());
                }


路径中文造成的把,转换下!!! --------------------编程问答-------------------- 改了还是一样的  --------------------编程问答--------------------
引用 2 楼 cq1029063251 的回复:
改了还是一样的 


server.mapath()用这个试试!后面没拼写对,你智能看下! --------------------编程问答--------------------
引用 2 楼 cq1029063251 的回复:
改了还是一样的 
我是读取后插入MSSQL
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,