视觉FoxPro连接问题 [英] Visual foxpro connection problem
问题描述
海,
在这里,我使用foxpro驱动程序提取提示数据.但是运行该代码后,我得到了错误
错误[42000] [Microsoft] [ODBC Visual FoxPro驱动程序]命令包含无法识别的短语/关键字.在ada.Fill(ds,"emp1")附近;
请给我一个思路以清除此问题,请plz告诉我,这是一种将提示文件直接提取到我们的.net应用程序中而不进入foxpro数据库的好方法.plz请记住,我仅对foxpro使用连接字符串,而不是数据库.查询适用于此.请清除我的疑问.
Hai,
Here I am using foxpro driver for extracting tally datas.But after running that code i am getting error
"ERROR [42000] [Microsoft][ODBC Visual FoxPro Driver]Command contains unrecognized phrase/keyword." near ada.Fill(ds, "emp1");
Please give me idea to clear this and plz tell me Is this a good way to extract tally files directly into our .net application without entering into foxpro database.Plz remember that I am using only connection string for foxpro.Not the database.The sql query is suitable for this.Plz clear my doubt.
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Odbc;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OdbcConnection con = new OdbcConnection("Dsn=MICROSOFT VISUAL FOXPRO;sourcedb=d:/Tally/BSheet.dbf;sourcetype=DBF;exclusive=No;backgroundfetch=Yes;collate=Machine;null=Yes;deleted=Yes");
con.Open();
OdbcDataAdapter ada = new OdbcDataAdapter(" Select $Name, $Parent, $Baseunits, $ClosingBalance, $ClosingValue from StockItem", con);
DataSet ds = new DataSet();
ada.Fill(ds, "emp1");
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
DataTable dt = ds.Tables["emp1"];
CreateCSVFile(dt, "c:\\zxxz.csv");
}
private void CreateCSVFile(DataTable dt, string p)
{
StreamWriter sw = new StreamWriter(p, false);
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
sw.Write(dt.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
foreach (DataRow dr in dt.Rows)
{
for (int i = 0; i < iColCount; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(dr[i].ToString());
}
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
}
sw.Close();
}
}
在Advance中感谢
Thanks in Advance
推荐答案
名称,
父项,
基本单元,
这篇关于视觉FoxPro连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!