日期:2014-05-17 浏览次数:20511 次
protected void Button1_Click(object sender, EventArgs e)
{
SXHD_DAL.DatabaseOper Dc = new DatabaseOper();
System.Data.Odbc.OdbcConnection conn_dbf = new System.Data.Odbc.OdbcConnection();
if (FileUpload1.PostedFile.ContentLength == 0)
{
Response.Write("<mce:script language=javascript><!--
alert('请选择需要导入的数据源!')
// --></mce:script>");
}
else
{
string fileName = FileUpload1.PostedFile.FileName.ToString();//获取dbf文件(包含路径)
//链接dbf数据库字符串
string connStr = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + fileName + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO";
conn_dbf.ConnectionString = connStr;
conn_dbf.Open(); //打开链接
string sql = "select * from " + fileName;
OdbcDataAdapter da = new OdbcDataAdapter(sql, conn_dbf);
DataTable dt = new DataTable();
da.Fill(dt);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)