Updating Datagridview

G

Guest

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?
 
G

Guest

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
 
K

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
------------------
 
G

Guest

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

I'm stumped

Ken Tucker said:
Hi,

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

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

Ken
------------------
Arne Beruldsen said:
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
 
R

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.
-------------------------
 
G

Guest

Defined as...

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top