对于不返回任何键列信息的 SelectCommand 不支持 UpdateCommand 的动态 SQL 生成。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidOperationException: 对于不返回任何键列信息的 SelectCommand 不支持 UpdateCommand 的动态 SQL 生成。源错误: 
行 47: // ds.Tables["List"].Rows[2].EndEdit();
行 48: 
行 49:  da.Update(ds,"List");
行 50: 
行 51:  DataGrid1.DataSource = ds.Tables["List"].DefaultView;
 

解决方案 »

  1.   

    将这些去掉
    DataRow dr = ds.Tables["List"].Rows[2]; dr.BeginEdit();
    dr["CustomerID"] = "++++++";
    dr["Address"] = "------";
    dr.EndEdit();// ds.Tables["List"].Rows[2].BeginEdit();
    // ds.Tables["List"].Rows[2]["CustomerID"] = "+++++";
    // ds.Tables["List"].Rows[2]["Address"] = "------";
    // ds.Tables["List"].Rows[2].EndEdit(); da.Update(ds,"List");换成这两个语句ds.Tables["List"].Rows[2]["CustomerID"] = "++++";
    ds.Tables["List"].Rows[2]["Adress"] = "-----";
      

  2.   

    1.string strSQL = "SELECT [CustomerID],[Address] FROM [Customers]";在这里给customerid字段建一索引
    2DataGrid1.DataSource = ds.Tables["List"].DefaultView;
    ==>DataGrid1.DataSource = ds.Tables["List"];
      

  3.   

    Shared Function HasMeisyou(ByVal Table As String, _
        ByVal Code As String, ByVal Text As String, ByVal meisyouValue As String) As Boolean
            Dim ConnectionString As String
            Dim meisyouAdapter As OracleDataAdapter
            Dim meisyouConnection As OracleConnection
            Dim meisyouCommand As OracleCommand
            Dim meisyouSelect As String        If Table Is Nothing Then
                Return False
            End If
            If Table.Equals(String.Empty) Then
                Return False
            End If
            If Code Is Nothing Then
                Return False
            End If
            If Code.Equals(String.Empty) Then
                Return False
            End If
            If Text Is Nothing Then
                Return False
            End If
            If Text.Equals(String.Empty) Then
                Return False
            End If
            If meisyouValue Is Nothing Then
                Return False
            End If
            If meisyouValue.Equals(String.Empty) Then
                Return False
            End If        meisyouConnection = New OracleConnection
            meisyouDataSet = New DataSet
            meisyouConnection = New OracleConnection
            meisyouAdapter = New OracleDataAdapter
            meisyouCommand = New OracleCommand        ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
            meisyouSelect = "select distinct " & Text & " from " & Table & " where " _
                & Code & "=:standName"
            meisyouConnection.ConnectionString = ConnectionString
            meisyouCommand.Connection = meisyouConnection
            meisyouCommand.CommandText = meisyouSelect
            meisyouCommand.Parameters.Add(":standName", OracleType.VarChar, 10)
            meisyouCommand.Parameters(":standName").Value = CType(meisyouValue, String)        Try
                meisyouAdapter.SelectCommand = meisyouCommand
                meisyouAdapter.Fill(meisyouDataSet)
                If Not CInt(meisyouDataSet.Tables(0).Rows.Count) = 0 Then
                    Return True
                Else
                    Return False
                End If
            Catch ex As Exception
                Return False
            End Try
        End Function
      

  4.   

    To:bushido(大饼)1.
    CustomerID字段,已经有一个索引!有重复索引!
    2.
    DataGrid1.DataSource = ds.Tables["List"].DefaultView;
    为什么要改为:DataGrid1.DataSource = ds.Tables["List"];
    我要的就是表List为默认表啊!=====================
    再说明一下!这个程序,如果用的是SQL数据库的话,是完全可以正确运行的,但用Access(OleDb)就出错!
      

  5.   

    To:fengliudai(大连理工)
    ==============================
    将这些去掉
    DataRow dr = ds.Tables["List"].Rows[2]; dr.BeginEdit();
    dr["CustomerID"] = "++++++";
    dr["Address"] = "------";
    dr.EndEdit();// ds.Tables["List"].Rows[2].BeginEdit();
    // ds.Tables["List"].Rows[2]["CustomerID"] = "+++++";
    // ds.Tables["List"].Rows[2]["Address"] = "------";
    // ds.Tables["List"].Rows[2].EndEdit(); da.Update(ds,"List");换成这两个语句ds.Tables["List"].Rows[2]["CustomerID"] = "++++";
    ds.Tables["List"].Rows[2]["Adress"] = "-----";
    ====================================老哥!你把Update去了那还有什么意义了!我就是要更新数据库!不是更数DataSet啊!再说,你的:
    ds.Tables["List"].Rows[2]["CustomerID"] = "++++";
    ds.Tables["List"].Rows[2]["Adress"] = "-----";
    这个后再用Update也是出错的!
    看我的注释里就有!