C# 使用对象数组时,表没有主键
sw仍然为空我的表如下C# 使用对象数组时,表没有主键,c#,sql,datatable,C#,Sql,Datatable,sw仍然为空我的表如下 byte[] movieCover = null; FileStream movieStream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read); BinaryReader movieReader = new BinaryReader(movieStream); movieCover = movieReader.ReadBytes((int)movieStream.Len
byte[] movieCover = null;
FileStream movieStream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
BinaryReader movieReader = new BinaryReader(movieStream);
movieCover = movieReader.ReadBytes((int)movieStream.Length);
var movieTable = MovieTable();
var Starwars = new object[2];
Starwars[0] = "Star Wars: Episode I - The Phantom Menace";
Starwars[1] = 1999; //Also tried using a string
var sw = movieTable.Rows.Find(Starwars);
我自己很努力地想解决这个问题,但我已经被困了好几天了!所有我想做的就是手动添加一张图片到它 终于解决了。要拉主键,请跟随 在调用Fill方法之前,需要将DataAdapter.MissingSchemaAction设置为MissingSchemaAction.AddWithKey
CREATE TABLE [dbo].[Movie] (
[Name] NVARCHAR (50) NOT NULL,
[Release Year] INT NOT NULL,
[Producer] NVARCHAR (50) NULL,
[Rating] INT NULL,
[Covor] IMAGE NULL,
[Description] TEXT NULL,
PRIMARY KEY CLUSTERED ([Name] ASC, [Release Year] ASC)
);
DataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;