楼上的兄弟,能说一下怎样去显式设置主键吗?在sql里面写吗?怎么写呢?谢谢你的回复。
解决方案 »
- 为什么不能使用Events
- 分页 的一个小问题。。。。。求救
- asp.net多线程
- asp.net网页布局中table和table之间总是有空白
- 如何清除requset.querystring获取到的参数???
- 高手来啊~求用Ajax实现按顺序显示多张图表的方法
- 急需Dotfuscator Professional Edition下载
- ASP.NET实时显示问题?
- 公司的邮箱系统有两个防火墙。。有时经常死掉。。请问如何用.NET实现一个小程序。。这个小程序可以随时检测这两个防火墙是否死掉。。。真
- 请问如何将DataGrid中列的值换成相应的名称??请教!!!
- 想在BODY第一次启动时显示某函数
- 怎样在DataGrid中动态创建templateColumn列
private void SetPrimaryKeys(){
// Create a new DataTable and set two DataColumn objects as primary keys.
DataTable myTable = new DataTable();
DataColumn[] keys = new DataColumn[2];
DataColumn myColumn;
// Create column 1.
myColumn = new DataColumn();
myColumn.DataType = System.Type.GetType("System.String");
myColumn.ColumnName= "FirstName";
// Add the column to the DataTable.Columns collection.
myTable.Columns.Add(myColumn);
// Add the column to the array.
keys[0] = myColumn; // Create column 2 and add it to the array.
myColumn = new DataColumn();
myColumn.DataType = System.Type.GetType("System.String");
myColumn.ColumnName = "LastName";
myTable.Columns.Add(myColumn);
// Add the column to the array.
keys[1] = myColumn;
// Set the PrimaryKeys property to the array.
myTable.PrimaryKey = keys;
}
但我现在疑惑的是:如果是单表查询,那么在fill前设置myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;就没问题;但改为联合查询,这样就不行了,说找不到主键。是不是联合查询是只能得到记录集,而不能得到约束信息等?请大家继续关注一下,谢谢了。