Updating Datagridview

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arne Beruldsen

    #1

    Updating Datagridview

    When I go to update my datagridview... I get this error

    Dynamic SQL generation for the UpdateCommand is not supported against a
    SelectCommand that does not return any key column information.

    using an update button...I have the following code:

    Dim cm As OleDb.OleDbComm andBuilder = New OleDb.OleDbComm andBuilder(SxAd apter)
    SxAdapter.Updat e(CType(SxSourc e.DataSource, DataTable))

    I'm using 2005

    Any ideas?
  • Ken Tucker [MVP]

    #2
    Re: Updating Datagridview

    Hi,

    What is the select command for SxAdapter?

    Ken
    --------------------------
    "Arne Beruldsen" <ArneBeruldsen@ discussions.mic rosoft.comwrote in message
    news:1DC63FFD-BC05-4382-A2C1-5CEF25DB0876@mi crosoft.com...
    When I go to update my datagridview... I get this error
    >
    Dynamic SQL generation for the UpdateCommand is not supported against a
    SelectCommand that does not return any key column information.
    >
    using an update button...I have the following code:
    >
    Dim cm As OleDb.OleDbComm andBuilder = New
    OleDb.OleDbComm andBuilder(SxAd apter)
    SxAdapter.Updat e(CType(SxSourc e.DataSource, DataTable))
    >
    I'm using 2005
    >
    Any ideas?

    Comment

    • Arne Beruldsen

      #3
      RE: Updating Datagridview

      Here is my GetData mod

      Private Sub GetData(ByVal selectCommand As String)
      Try
      Dim Cxx As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
      Source= " & Application.Sta rtupPath & "\zAdmin.mdb;Us er Id=admin;Passwo rd=;"
      SQL = "Select LastName, FirstName, Date, Score from Scores"
      ' Create a new data adapter based on the specified query.
      SxAdapter = New OleDbDataAdapte r(SQL, Cxx)
      Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
      Dim SxTable As New DataTable()
      SxTable.Locale = System.Globaliz ation.CultureIn fo.InvariantCul ture
      SxAdapter.Fill( SxTable)
      SxSource.DataSo urce = SxTable
      Catch ex As OleDbException
      MessageBox.Show ("Error")
      End Try
      End Sub



      "Arne Beruldsen" wrote:
      When I go to update my datagridview... I get this error
      >
      Dynamic SQL generation for the UpdateCommand is not supported against a
      SelectCommand that does not return any key column information.
      >
      using an update button...I have the following code:
      >
      Dim cm As OleDb.OleDbComm andBuilder = New OleDb.OleDbComm andBuilder(SxAd apter)
      SxAdapter.Updat e(CType(SxSourc e.DataSource, DataTable))
      >
      I'm using 2005
      >
      Any ideas?

      Comment

      • Ken Tucker [MVP]

        #4
        Re: Updating Datagridview

        Hi,

        I think date is an keyword. Try this for the select statement

        SQL = "Select LastName, FirstName, [Date], Score from Scores"

        Ken
        ------------------
        "Arne Beruldsen" <ArneBeruldsen@ discussions.mic rosoft.comwrote in message
        news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@mi crosoft.com...
        Here is my GetData mod
        >
        Private Sub GetData(ByVal selectCommand As String)
        Try
        Dim Cxx As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
        Source= " & Application.Sta rtupPath & "\zAdmin.mdb;Us er
        Id=admin;Passwo rd=;"
        SQL = "Select LastName, FirstName, Date, Score from Scores"
        ' Create a new data adapter based on the specified query.
        SxAdapter = New OleDbDataAdapte r(SQL, Cxx)
        Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
        Dim SxTable As New DataTable()
        SxTable.Locale =
        System.Globaliz ation.CultureIn fo.InvariantCul ture
        SxAdapter.Fill( SxTable)
        SxSource.DataSo urce = SxTable
        Catch ex As OleDbException
        MessageBox.Show ("Error")
        End Try
        End Sub
        >
        >
        >
        "Arne Beruldsen" wrote:
        >
        >When I go to update my datagridview... I get this error
        >>
        >Dynamic SQL generation for the UpdateCommand is not supported against a
        >SelectComman d that does not return any key column information.
        >>
        >using an update button...I have the following code:
        >>
        >Dim cm As OleDb.OleDbComm andBuilder = New
        >OleDb.OleDbCom mandBuilder(SxA dapter)
        >SxAdapter.Upda te(CType(SxSour ce.DataSource, DataTable))
        >>
        >I'm using 2005
        >>
        >Any ideas?

        Comment

        • Arne Beruldsen

          #5
          Re: Updating Datagridview

          Good thought but still didn't work...I even changed the column to
          TestDate...stil l no luck...:(

          I'm stumped

          "Ken Tucker [MVP]" wrote:
          Hi,
          >
          I think date is an keyword. Try this for the select statement
          >
          SQL = "Select LastName, FirstName, [Date], Score from Scores"
          >
          Ken
          ------------------
          "Arne Beruldsen" <ArneBeruldsen@ discussions.mic rosoft.comwrote in message
          news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@mi crosoft.com...
          Here is my GetData mod

          Private Sub GetData(ByVal selectCommand As String)
          Try
          Dim Cxx As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
          Source= " & Application.Sta rtupPath & "\zAdmin.mdb;Us er
          Id=admin;Passwo rd=;"
          SQL = "Select LastName, FirstName, Date, Score from Scores"
          ' Create a new data adapter based on the specified query.
          SxAdapter = New OleDbDataAdapte r(SQL, Cxx)
          Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
          Dim SxTable As New DataTable()
          SxTable.Locale =
          System.Globaliz ation.CultureIn fo.InvariantCul ture
          SxAdapter.Fill( SxTable)
          SxSource.DataSo urce = SxTable
          Catch ex As OleDbException
          MessageBox.Show ("Error")
          End Try
          End Sub



          "Arne Beruldsen" wrote:
          When I go to update my datagridview... I get this error
          >
          Dynamic SQL generation for the UpdateCommand is not supported against a
          SelectCommand that does not return any key column information.
          >
          using an update button...I have the following code:
          >
          Dim cm As OleDb.OleDbComm andBuilder = New
          OleDb.OleDbComm andBuilder(SxAd apter)
          SxAdapter.Updat e(CType(SxSourc e.DataSource, DataTable))
          >
          I'm using 2005
          >
          Any ideas?
          >
          >

          Comment

          • RobinS

            #6
            Re: Updating Datagridview

            VB2005 or 2003?

            Robin S.
            --------------------------------
            "Arne Beruldsen" <ArneBeruldsen@ discussions.mic rosoft.comwrote in message
            news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@mi crosoft.com...
            Here is my GetData mod
            >
            Private Sub GetData(ByVal selectCommand As String)
            Try
            Dim Cxx As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
            Source= " & Application.Sta rtupPath & "\zAdmin.mdb;Us er
            Id=admin;Passwo rd=;"
            SQL = "Select LastName, FirstName, Date, Score from Scores"
            ' Create a new data adapter based on the specified query.
            SxAdapter = New OleDbDataAdapte r(SQL, Cxx)
            Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
            Dim SxTable As New DataTable()
            SxTable.Locale =
            System.Globaliz ation.CultureIn fo.InvariantCul ture
            SxAdapter.Fill( SxTable)
            SxSource.DataSo urce = SxTable
            Catch ex As OleDbException
            MessageBox.Show ("Error")
            End Try
            End Sub
            >
            >
            >
            "Arne Beruldsen" wrote:
            >
            >When I go to update my datagridview... I get this error
            >>
            >Dynamic SQL generation for the UpdateCommand is not supported against a
            >SelectComman d that does not return any key column information.
            >>
            >using an update button...I have the following code:
            >>
            >Dim cm As OleDb.OleDbComm andBuilder = New
            >OleDb.OleDbCom mandBuilder(SxA dapter)
            >SxAdapter.Upda te(CType(SxSour ce.DataSource, DataTable))
            >>
            >I'm using 2005
            >>
            >Any ideas?

            Comment

            • RobinS

              #7
              Re: Updating Datagridview

              Do you have Option Strict On and Option Explicit On, just to make sure
              all of your variables are defined, and correctly?

              Where are Sql, SxAdapter, and SxSource defined, and as what?

              Robin S.
              -------------------------

              "Arne Beruldsen" <ArneBeruldsen@ discussions.mic rosoft.comwrote in message
              news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@mi crosoft.com...
              Here is my GetData mod
              >
              Private Sub GetData(ByVal selectCommand As String)
              Try
              Dim Cxx As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
              Source= " & Application.Sta rtupPath & "\zAdmin.mdb;Us er
              Id=admin;Passwo rd=;"
              SQL = "Select LastName, FirstName, Date, Score from Scores"
              ' Create a new data adapter based on the specified query.
              SxAdapter = New OleDbDataAdapte r(SQL, Cxx)
              Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
              Dim SxTable As New DataTable()
              SxTable.Locale =
              System.Globaliz ation.CultureIn fo.InvariantCul ture
              SxAdapter.Fill( SxTable)
              SxSource.DataSo urce = SxTable
              Catch ex As OleDbException
              MessageBox.Show ("Error")
              End Try
              End Sub
              >
              >
              >
              "Arne Beruldsen" wrote:
              >
              >When I go to update my datagridview... I get this error
              >>
              >Dynamic SQL generation for the UpdateCommand is not supported against a
              >SelectComman d that does not return any key column information.
              >>
              >using an update button...I have the following code:
              >>
              >Dim cm As OleDb.OleDbComm andBuilder = New
              >OleDb.OleDbCom mandBuilder(SxA dapter)
              >SxAdapter.Upda te(CType(SxSour ce.DataSource, DataTable))
              >>
              >I'm using 2005
              >>
              >Any ideas?

              Comment

              • Arne Beruldsen

                #8
                Re: Updating Datagridview

                Defined as...

                Private SxAdapter As New OleDbDataAdapte r()
                Private SxSource As New BindingSource()



                "RobinS" wrote:
                Do you have Option Strict On and Option Explicit On, just to make sure
                all of your variables are defined, and correctly?
                >
                Where are Sql, SxAdapter, and SxSource defined, and as what?
                >
                Robin S.
                -------------------------
                >
                "Arne Beruldsen" <ArneBeruldsen@ discussions.mic rosoft.comwrote in message
                news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@mi crosoft.com...
                Here is my GetData mod

                Private Sub GetData(ByVal selectCommand As String)
                Try
                Dim Cxx As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
                Source= " & Application.Sta rtupPath & "\zAdmin.mdb;Us er
                Id=admin;Passwo rd=;"
                SQL = "Select LastName, FirstName, Date, Score from Scores"
                ' Create a new data adapter based on the specified query.
                SxAdapter = New OleDbDataAdapte r(SQL, Cxx)
                Dim MyCommandBuilde r As New OleDbCommandBui lder(SxAdapter)
                Dim SxTable As New DataTable()
                SxTable.Locale =
                System.Globaliz ation.CultureIn fo.InvariantCul ture
                SxAdapter.Fill( SxTable)
                SxSource.DataSo urce = SxTable
                Catch ex As OleDbException
                MessageBox.Show ("Error")
                End Try
                End Sub



                "Arne Beruldsen" wrote:
                When I go to update my datagridview... I get this error
                >
                Dynamic SQL generation for the UpdateCommand is not supported against a
                SelectCommand that does not return any key column information.
                >
                using an update button...I have the following code:
                >
                Dim cm As OleDb.OleDbComm andBuilder = New
                OleDb.OleDbComm andBuilder(SxAd apter)
                SxAdapter.Updat e(CType(SxSourc e.DataSource, DataTable))
                >
                I'm using 2005
                >
                Any ideas?
                >
                >
                >

                Comment

                Working...