467,207 Members | 1,298 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,207 developers. It's quick & easy.

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.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(SxAdapter)
SxAdapter.Update(CType(SxSource.DataSource, DataTable))

I'm using 2005

Any ideas?
Nov 27 '06 #1
  • viewed: 3100
Share:
7 Replies
Hi,

What is the select command for SxAdapter?

Ken
--------------------------
"Arne Beruldsen" <Ar***********@discussions.microsoft.comwrote in message
news:1D**********************************@microsof t.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?
Nov 27 '06 #2
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?
Nov 27 '06 #3
Hi,

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

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

Ken
------------------
"Arne Beruldsen" <Ar***********@discussions.microsoft.comwrote in message
news:EF**********************************@microsof t.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?
Nov 27 '06 #4
Good thought but still didn't work...I even changed the column to
TestDate...still 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" <Ar***********@discussions.microsoft.comwrote in message
news:EF**********************************@microsof t.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?

Nov 27 '06 #5
VB2005 or 2003?

Robin S.
--------------------------------
"Arne Beruldsen" <Ar***********@discussions.microsoft.comwrote in message
news:EF**********************************@microsof t.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?

Nov 27 '06 #6
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" <Ar***********@discussions.microsoft.comwrote in message
news:EF**********************************@microsof t.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?

Nov 27 '06 #7
Defined as...

Private SxAdapter As New OleDbDataAdapter()
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" <Ar***********@discussions.microsoft.comwrote in message
news:EF**********************************@microsof t.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?


Nov 27 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by bob@datasync.com | last post: by
3 posts views Thread by Carlos Cruz | last post: by
5 posts views Thread by JimmyKoolPantz | last post: by
1 post views Thread by weird0 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.