Home All Groups Group Topic Archive Search About

Updating Datagridview

Author
27 Nov 2006 12:41 AM
Arne Beruldsen
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.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(SxAdapter)
SxAdapter.Update(CType(SxSource.DataSource, DataTable))

I'm using 2005

Any ideas?

Author
27 Nov 2006 1:16 AM
Ken Tucker [MVP]
Hi,

        What is the select command for SxAdapter?

Ken
--------------------------
Show quoteHide quote
"Arne Beruldsen" <ArneBeruld***@discussions.microsoft.com> wrote in message
news:1DC63FFD-BC05-4382-A2C1-5CEF25DB0876@microsoft.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.OleDbCommandBuilder = New
> OleDb.OleDbCommandBuilder(SxAdapter)
> SxAdapter.Update(CType(SxSource.DataSource, DataTable))
>
> I'm using 2005
>
> Any ideas?
Author
27 Nov 2006 1:24 AM
Arne Beruldsen
Here is my GetData mod

Private Sub GetData(ByVal selectCommand As String)
        Try
            Dim Cxx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source= " & Application.StartupPath & "\zAdmin.mdb;User Id=admin;Password=;"
            SQL = "Select LastName, FirstName, Date, Score from Scores"
            ' Create a new data adapter based on the specified query.
            SxAdapter = New OleDbDataAdapter(SQL, Cxx)
            Dim MyCommandBuilder As New OleDbCommandBuilder(SxAdapter)
            Dim SxTable As New DataTable()
            SxTable.Locale = System.Globalization.CultureInfo.InvariantCulture
            SxAdapter.Fill(SxTable)
            SxSource.DataSource = SxTable
        Catch ex As OleDbException
            MessageBox.Show("Error")
        End Try
    End Sub



Show quoteHide quote
"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.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(SxAdapter)
> SxAdapter.Update(CType(SxSource.DataSource, DataTable))
>
> I'm using 2005
>
> Any ideas?
Author
27 Nov 2006 1:43 AM
Ken Tucker [MVP]
Hi,

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

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

Ken
------------------
Show quoteHide quote
"Arne Beruldsen" <ArneBeruld***@discussions.microsoft.com> wrote in message
news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@microsoft.com...
> Here is my GetData mod
>
> Private Sub GetData(ByVal selectCommand As String)
>        Try
>            Dim Cxx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source= " & Application.StartupPath & "\zAdmin.mdb;User
> Id=admin;Password=;"
>            SQL = "Select LastName, FirstName, Date, Score from Scores"
>            ' Create a new data adapter based on the specified query.
>            SxAdapter = New OleDbDataAdapter(SQL, Cxx)
>            Dim MyCommandBuilder As New OleDbCommandBuilder(SxAdapter)
>            Dim SxTable As New DataTable()
>            SxTable.Locale =
> System.Globalization.CultureInfo.InvariantCulture
>            SxAdapter.Fill(SxTable)
>            SxSource.DataSource = 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.OleDbCommandBuilder = New
>> OleDb.OleDbCommandBuilder(SxAdapter)
>> SxAdapter.Update(CType(SxSource.DataSource, DataTable))
>>
>> I'm using 2005
>>
>> Any ideas?
Author
27 Nov 2006 2:31 AM
Arne Beruldsen
Good thought but still didn't work...I even changed the column to
TestDate...still no luck...:(

I'm stumped

Show quoteHide quote
"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" <ArneBeruld***@discussions.microsoft.com> wrote in message
> news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@microsoft.com...
> > Here is my GetData mod
> >
> > Private Sub GetData(ByVal selectCommand As String)
> >        Try
> >            Dim Cxx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source= " & Application.StartupPath & "\zAdmin.mdb;User
> > Id=admin;Password=;"
> >            SQL = "Select LastName, FirstName, Date, Score from Scores"
> >            ' Create a new data adapter based on the specified query.
> >            SxAdapter = New OleDbDataAdapter(SQL, Cxx)
> >            Dim MyCommandBuilder As New OleDbCommandBuilder(SxAdapter)
> >            Dim SxTable As New DataTable()
> >            SxTable.Locale =
> > System.Globalization.CultureInfo.InvariantCulture
> >            SxAdapter.Fill(SxTable)
> >            SxSource.DataSource = 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.OleDbCommandBuilder = New
> >> OleDb.OleDbCommandBuilder(SxAdapter)
> >> SxAdapter.Update(CType(SxSource.DataSource, DataTable))
> >>
> >> I'm using 2005
> >>
> >> Any ideas?
>
>
Author
27 Nov 2006 3:45 AM
RobinS
VB2005 or 2003?

Robin S.
--------------------------------
Show quoteHide quote
"Arne Beruldsen" <ArneBeruld***@discussions.microsoft.com> wrote in message
news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@microsoft.com...
> Here is my GetData mod
>
> Private Sub GetData(ByVal selectCommand As String)
>        Try
>            Dim Cxx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source= " & Application.StartupPath & "\zAdmin.mdb;User
> Id=admin;Password=;"
>            SQL = "Select LastName, FirstName, Date, Score from Scores"
>            ' Create a new data adapter based on the specified query.
>            SxAdapter = New OleDbDataAdapter(SQL, Cxx)
>            Dim MyCommandBuilder As New OleDbCommandBuilder(SxAdapter)
>            Dim SxTable As New DataTable()
>            SxTable.Locale =
> System.Globalization.CultureInfo.InvariantCulture
>            SxAdapter.Fill(SxTable)
>            SxSource.DataSource = 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.OleDbCommandBuilder = New
>> OleDb.OleDbCommandBuilder(SxAdapter)
>> SxAdapter.Update(CType(SxSource.DataSource, DataTable))
>>
>> I'm using 2005
>>
>> Any ideas?
Author
27 Nov 2006 3:50 AM
RobinS
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.
-------------------------

Show quoteHide quote
"Arne Beruldsen" <ArneBeruld***@discussions.microsoft.com> wrote in message
news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@microsoft.com...
> Here is my GetData mod
>
> Private Sub GetData(ByVal selectCommand As String)
>        Try
>            Dim Cxx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source= " & Application.StartupPath & "\zAdmin.mdb;User
> Id=admin;Password=;"
>            SQL = "Select LastName, FirstName, Date, Score from Scores"
>            ' Create a new data adapter based on the specified query.
>            SxAdapter = New OleDbDataAdapter(SQL, Cxx)
>            Dim MyCommandBuilder As New OleDbCommandBuilder(SxAdapter)
>            Dim SxTable As New DataTable()
>            SxTable.Locale =
> System.Globalization.CultureInfo.InvariantCulture
>            SxAdapter.Fill(SxTable)
>            SxSource.DataSource = 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.OleDbCommandBuilder = New
>> OleDb.OleDbCommandBuilder(SxAdapter)
>> SxAdapter.Update(CType(SxSource.DataSource, DataTable))
>>
>> I'm using 2005
>>
>> Any ideas?
Author
27 Nov 2006 4:29 AM
Arne Beruldsen
Defined as...

Private SxAdapter As New OleDbDataAdapter()
Private SxSource As New BindingSource()



Show quoteHide quote
"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" <ArneBeruld***@discussions.microsoft.com> wrote in message
> news:EF3BD3B7-1133-4353-9EB3-F9816ABB7BC7@microsoft.com...
> > Here is my GetData mod
> >
> > Private Sub GetData(ByVal selectCommand As String)
> >        Try
> >            Dim Cxx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source= " & Application.StartupPath & "\zAdmin.mdb;User
> > Id=admin;Password=;"
> >            SQL = "Select LastName, FirstName, Date, Score from Scores"
> >            ' Create a new data adapter based on the specified query.
> >            SxAdapter = New OleDbDataAdapter(SQL, Cxx)
> >            Dim MyCommandBuilder As New OleDbCommandBuilder(SxAdapter)
> >            Dim SxTable As New DataTable()
> >            SxTable.Locale =
> > System.Globalization.CultureInfo.InvariantCulture
> >            SxAdapter.Fill(SxTable)
> >            SxSource.DataSource = 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.OleDbCommandBuilder = New
> >> OleDb.OleDbCommandBuilder(SxAdapter)
> >> SxAdapter.Update(CType(SxSource.DataSource, DataTable))
> >>
> >> I'm using 2005
> >>
> >> Any ideas?
>
>
>