一个数据,其中一张Client表,创建了ClientTableAdapter,且已经自动生成了insert,updata等命令现在我在类中创建了
ClientTableAdapter myadapter=new ClientTableAdapter();myadapter.insert(......);然后还需要其他命令么?按照MSDN上说的好像应该直接可以写入到数据库了
但现在我实际中无法实现

解决方案 »

  1.   

    public static void AddClient()
            {            WnssDataDataSetTableAdapters.ClientTableAdapter clientAdapter = new WNSS.WnssDataDataSetTableAdapters.ClientTableAdapter();            clientAdapter.Insert(testClientIP, "wu", DateTime.Now);        }
      

  2.   

    在调用update那句,设个断点,检查Adapter相关的updateCommnad/insertcommand指令是否正确.
      

  3.   

    insertcommand是正确的,但是执行时,执行不到insert那段定义的函数
    就是下面这段函数,应该是执行的,但单步的时候,发现没有经过
     public virtual int Insert(string ClientIP, string ClientName, global::System.Nullable<global::System.DateTime> LogTime) {
                if ((ClientIP == null)) {
                    throw new global::System.ArgumentNullException("ClientIP");
                }
                else {
                    this.Adapter.InsertCommand.Parameters[0].Value = ((string)(ClientIP));
                }
                if ((ClientName == null)) {
    ..........
      

  4.   

    我发现问题所在了,我原来用的是连接到mdf文件现在改成直接连接就好了是不是用mdf文件就不行啊?