首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

c#如何获取access的主键字段

2012-01-08 
c#怎么获取access的主键字段哪位知道,请帮帮我,有急用![解决办法]access没有自动增长列,你在程序插入的时

c#怎么获取access的主键字段
哪位知道,请帮帮我,有急用!

[解决办法]
access没有自动增长列,你在程序插入的时候就判断最大值后加一
不要重复,这个字段就成主键值了
[解决办法]
try:

OleDbConnection cnn = new ...;
OleDbDataAdapter da = new ....( "select * from table1 ",cnn);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
DataTable dt = new ...
da.Fill(dt);
//通过PrimaryKey属性取主键
Response.Write(dt.PrimaryKey[0].ColumnName);

热点排行