如果换成
ls_sql="select gw_liucheng_person.pid "+
" from GONGWEN_LIUCHENG_PERSON,GongWen_liucheng"+
" where GongWen_liucheng.GWID=GONGWEN_LIUCHENG_PERSON.GWID "+
"and GongWen_liucheng.bzid=GONGWEN_LIUCHENG_PERSON.bzid "+
"and GongWen_liucheng.GWID=1 ";
......
my_da.Fill(my_ds,"gw_liucheng_person");
就没错。奇怪啊?表名打错了,gongwen=gw,呵呵
ls_sql="select gw_liucheng_person.pid "+
" from GONGWEN_LIUCHENG_PERSON,GongWen_liucheng"+
" where GongWen_liucheng.GWID=GONGWEN_LIUCHENG_PERSON.GWID "+
"and GongWen_liucheng.bzid=GONGWEN_LIUCHENG_PERSON.bzid "+
"and GongWen_liucheng.GWID=1 ";
......
my_da.Fill(my_ds,"gw_liucheng_person");
就没错。奇怪啊?表名打错了,gongwen=gw,呵呵
解决方案 »
- asp.net mvc spring.net nhibernate错误'hibernate' node cannot be resolved for the s
- ASP.NET下SQL,将A表某类数据添加到B表里面
- 急 急 急 急 急
- |M| 今天看了别人写的一个SqlHelper 大家看看这里是什么意思
- ===========急啊.当退出某个页面时如何删除一个目录下的所有文件========谢谢
- 两个简单小问题 每个50分!!!(在线 答对立即给分)
- 一个很低级的问题
- asp.net中调用EXCEL接口程序运行不稳定
- 有与java下ajax框架thinwire,相似的,net ajax框架吗?
- <pages enableEventValidation="true"/> 这个是什么意思?
- 疯了,找张四川地图都找不到,55555,四川的朋友来看看。
- 串行化意义何在?
//首先建立一个新项dataset,里面建立一个没有数据的元素,包含报表中需要的数据,并加一个id设为主健,通过dataset生成.rpt文件;下边设生成数据和邦顶的过程。
DataSet1 ds=new DataSet1();
xscjtj orc = new xscjtj();
int i=0 ,j;
string str_kc="";
conf.open();
strsql="SELECT t_xscjb.xq, V_kcbm.bmnr, t_xsjbxx.xsbh, t_xsjbxx.xm, t_xscjb.kccj, t_xsjbxx.sxsdm, t_xsjbxx.xxdm FROM jxgl.dbo.t_xsjbxx t_xsjbxx INNER JOIN jxgl.dbo.t_xscjb t_xscjb ON t_xsjbxx.xsbh=t_xscjb.xsbh INNER JOIN jxgl.dbo.V_kcbm V_kcbm ON t_xscjb.kcbh=V_kcbm.bm WHERE (t_xsjbxx.sxsdm='41' AND t_xsjbxx.xxdm='4109'";
cmd.CommandText=strsql;
cmd.Connection=conf.Myconn;
dr=cmd.ExecuteReader();
while(dr.Read())
{
DataRow r=ds.Tables[0].NewRow();
r["id"]=i++;
r["xq"]=dr["xq"].ToString().Trim();
r["bmnr"]=dr["bmnr"].ToString().Trim();
r["xsbh"]=dr["xsbh"].ToString().Trim();
r["xm"]=dr["xm"].ToString().Trim();
r["kccj"]=dr["kccj"].ToString().Trim();
ds.Tables[0].Rows.Add(r);
}
conf.close();
orc.SetDataSource(ds);
this.CRV_xscjgl.ReportSource = orc;
问题:
异常详细信息: System.Data.ConstraintException: 未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值。
------------------------------------------------
解决方案:
DataSet.EnforceConstraints = false;DataSet.EnforceConstraints 属性
DataSet 类 | DataSet 成员 | System.Data 命名空间 | Constraints | ConstraintException | ForeignKeyConstraint | DataTable | UniqueConstraint
获取或设置一个值,该值指示在尝试执行任何更新操作时是否遵循约束规则。
[Visual Basic]
<Serializable>
Public Property EnforceConstraints As Boolean
[C#]
[Serializable]
public bool EnforceConstraints {get; set;}
属性值
如果实施规则,则为 true;否则为 false。默认为 true。
异常
异常类型 条件
ConstraintException 无法实施一个或多个约束。
备注
有关详细信息,请参阅 Constraints 属性。
示例
[Visual Basic, C#] 以下示例创建一个 DataSet,该数据集包含一个表、一个列、五个行和一个 UniqueConstraint。EnforceConstraints 属性被设置为 false,每一行的值都设置为同一个值。如果 EnforceConstraints 属性被重置为 true,则生成 ConstraintException。
[Visual Basic]
Private Sub DemonstrateEnforceConstraints()
' Create a DataSet with one table, one column and a UniqueConstraint.
Dim ds As DataSet = New DataSet("myDataSet")
Dim t As DataTable = New DataTable("myTable")
Dim c As DataColumn = New DataColumn("col1")
c.Unique = True
t.Columns.Add(c)
ds.Tables.Add(t)
Console.WriteLine("constraints.count: " & t.Constraints.Count)
' add five rows.
Dim r As DataRow
Dim i As Integer
For i = 0 To 4 r = t.NewRow()
r("col1") = i
t.Rows.Add(r)
Next
t.AcceptChanges()
ds.EnforceConstraints = False
' Change the values of all rows to 1.
Dim thisRow As DataRow
For Each thisRow In t.rows
thisRow("col1") = 1
Next Try
ds.EnforceConstraints = True
Catch ex As System.Data.ConstraintException
Console.WriteLine("ConstraintException: " + ex.Message)
End Try
End Sub
[C#]
private void DemonstrateEnforceConstraints(){
// Create a DataSet with one table, one column and a UniqueConstraint.
DataSet ds= new DataSet("myDataSet");
DataTable t = new DataTable("myTable");
DataColumn c = new DataColumn("col1");
// A UniqueConstraint is added when the Unique property is true.
c.Unique=true;
t.Columns.Add(c);
ds.Tables.Add(t);
Console.WriteLine("constraints.count: " + t.Constraints.Count);
// add five rows.
DataRow r ;
for(int i=0;i<5;i++){
r = t.NewRow();
r["col1"] = i;
t.Rows.Add(r);
}
t.AcceptChanges();
ds.EnforceConstraints=false;
// Change the values of all rows to 1.
foreach(DataRow thisRow in t.Rows){
thisRow["col1"]=1;
//Console.WriteLine("\t" + thisRow[0]);
}
try{
ds.EnforceConstraints=true;
}
catch(System.Data.ConstraintException ex){
Console.WriteLine("ConstraintException: " + ex.Message);
}
catch(System.Exception sysEx){
Console.WriteLine(sysEx.GetType().Name);
Console.WriteLine(sysEx.Message);
}
}