• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1074
  • Last Modified:

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

I have the following.
In my dataset I have the table listed and there is a primary key.

using System.Data.SqlClient;

Datasetname dt = new Datasetname ();
command.CommandText = "Select * from table1"
adapter.SelectCommand = command;
adapter.Fill (dt, "table1");
SqlCommandBuilder commandb = new SqlCommandBuilder(adapter);
adapter.UpdateCommand = commandb.GetUpdateCommand();

I get the error:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information

I have no idea why.
0
bman9111
Asked:
bman9111
  • 2
1 Solution
 
dstanley9Commented:
does table1 have a primary key in the database? (not in yout dataset)
0
 
bman9111Author Commented:
yes it does
0
 
dstanley9Commented:
Can you generate a CREATE script for table1 from SQL Server?  It seems that the SqlCommandBuilder is not able to determine what the primary key is.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now