为了使员工的工作自动化,任务是自动集成客户记录。使用数据库foxpro(dbf)在程序中维护客户端库。我正在尝试在数据库中手动创建测试记录,但是当向其中一个字段添加值时,出现错误:
System.Data.OleDb.OleDbException: "Function is not implemented."
我创建了一个用于数据库的类对象:
WDBF db = new WDBF();
db.CreateOleDbCommand("INSERT INTO CLNDATES (" +
"CLIENT_CODE, " +
"LAST_NAME, " +
"FIRST_NAME, " +
"FAMILY, " +
"HOME_PH_NUMBER," +
"OFFICE_PH_NUMBER ," +
"CARD_CODE, " +
"ADD_DATES ," +
"CONTRACT,"+
"CREDIT," +
"PROC_T," +
"PROC_O," +
"MAIL," +
"FILE_PHOTO, " +
"RISK," +
"WORKPLACE," +
"KDG," +
"NATIONALITY," +
"REGION," +
"ADDRESS," +
"MG," +
"INSURER_CODE," +
"BONUSTYPE," +
"DISCOUNTCARD," +
"BONUSCOMMENT," +
"DOCTOR," +
"POST," +
"POSTDATE," +
"VILLAGE," +
"DOGOVOR_FROM," +
"PASSPORT," +
"AGENT," +
"INVALID" +
"" +
"" +
") " +
"VALUES(" +
"?,?,?,?,?," +
"?,?,?,?,?," +
"?,?,?,?,?," +
"?,?,?,?,?," +
"?,?,?,?,?," +
"?,?,?,?,?," +
"?,?,?" +
")");
接下来,我打开连接并尝试执行INSERT命令。
using (StreamReader w = new StreamReader("conf.txt"))
conf = w.ReadLine();
_connection.ConnectionString = @"Provider=vfpoledb;" + conf + ";Collating Sequence=machine; Exclusive=No";
_connection.Open();
OleDbCommand command = new
OleDbCommand(queryString, _connection);
command.Parameters.Add("CLIENT_CODE", OleDbType.Char).Value= 85919607;
command.Parameters.Add("HOME_PH_NUMBER", OleDbType.Char).Value = 1111;
command.Parameters.Add("OFFICE_PH_NUMBER", OleDbType.Char).Value = 1111;
command.Parameters.Add("FIRST_NAME", OleDbType.Char).Value = "test";
command.Parameters.Add("FAMILY", OleDbType.Char).Value = "test";
command.Parameters.Add("LAST_NAME", OleDbType.Char).Value = "test";
command.Parameters.Add("CARD_CODE", OleDbType.Char).Value = "";
command.Parameters.Add("ADD_DATES", OleDbType.Char).Value = "";
command.Parameters.Add("CONTRACT", OleDbType.Char).Value = "";
command.Parameters.Add("CREDIT", OleDbType.Double).Value = 0;
command.Parameters.Add("PROC_T", OleDbType.Double).Value = 0;
command.Parameters.Add("PROC_O", OleDbType.Double).Value = 0;
command.Parameters.Add("MAIL", OleDbType.Char).Value = "";
command.Parameters.Add("FILE_PHOTO", OleDbType.Char).Value = "";
command.Parameters.Add("RISK", OleDbType.Char).Value = "";
command.Parameters.Add("WORKPLACE", OleDbType.Char).Value = "";
command.Parameters.Add("KDG", OleDbType.Char).Value = "";
command.Parameters.Add("NATIONALITY", OleDbType.Char).Value = "";
command.Parameters.Add("REGION", OleDbType.Char).Value = "";
command.Parameters.Add("ADDRESS", OleDbType.Char).Value = "";
command.Parameters.Add("MG", OleDbType.Char).Value = "";
command.Parameters.Add("INSURER_CODE", OleDbType.Char).Value = "";
command.Parameters.Add("BONUSTYPE", OleDbType.Char).Value = "";
command.Parameters.Add("DISCOUNTCARD", OleDbType.Char).Value = "";
command.Parameters.Add("BONUSCOMMENT", OleDbType.Char).Value = "";
command.Parameters.Add("DOCTOR", OleDbType.Char).Value = "";
command.Parameters.Add("POST", OleDbType.Char).Value = "";
command.Parameters.Add("POSTDATE", OleDbType.Date).Value =null;
command.Parameters.Add("VILLAGE", OleDbType.Date).Value = null;
command.Parameters.Add("DOGOVOR_FROM", OleDbType.Date).Value = null;
command.Parameters.Add("PASSPORT", OleDbType.Char).Value = null;
command.Parameters.Add("AGENT", OleDbType.Char).Value = null;
command.Parameters.Add("INVALID", OleDbType.Char).Value = null;
command.ExecuteNonQuery();
添加时出现错误
command.Parameters.Add("INVALID", OleDbType.Char).Value = null;
添加空字符串时,错误仍然存在:
command.Parameters.Add ("INVALID", OleDbType.Char) .Value = "";
浏览了不同类型的数据,但该错误不会消失。可能是什么问题呢?抱歉,我的英语不好。
UPD1:
我试图从同一软件向另一张表添加行。插入没有错误。为了不列出所有列,而仅填写必要的列,对代码进行了更改。
db.CreateOleDbCommand("INSERT INTO cln_actions (CLIENT_CODE) " + "VALUES(?)");
public void CreateOleDbCommand(string queryString)
{
if(_connection != null)
{
_connection.Open();
OleDbCommand command = new
OleDbCommand(queryString, _connection);
command.Parameters.Add("[CLIENT_CODE]", OleDbType.Char).Value = "test";
new OleDbCommand("set null off", _connection).ExecuteNonQuery();
int x = command.ExecuteNonQuery();
}}