问题描述
您好。我的代码工作得很好,除了所有数据都没有提供ds.relations代码。你能看出我做错了什么或者我需要添加什么。代码如下
Dim adapter As OdbcDataAdapter = New OdbcDataAdapter(command)
Dim ds As DataSet = New DataSet()
adapter.SelectCommand =新的OdbcCommand(" select rmsfiles2.obcop200.line#,rmsfiles2.obcop200.ordno,rmsfiles2.obcop200.quano,rmsfiles2.obcop200.quana,rmsfiles2.obcop200.quans,rmsfiles2.obcop200.c2rdt,rmsfiles2.obcop200.unitm,rmsfiles2来自rmsfiles2.obcop200的.obcop200.actsp,rmsfiles2.obcop200.prdno,其中ordno ="& Order.ToString(),myConnection)
adapter.Fill(ds," OBCOP200")
adapter.SelectCommand = New OdbcCommand(" select rmsfiles2.mspmp100.ptyp1,rmsfiles2.mspmp100.ptyp2,rmsfiles2.mspmp100.descp,rmsfiles2.mspmp100.prdno from rmsfiles2.obcop200 inner join rmsfiles2 .mspmp100 on rmsfiles2.obcop200.prdno = rmsfiles2.mspmp100.prdno其中rmsfiles2.obcop200.ordno ="& Order.ToString(),myConnection)
adapter.Fill(ds,&quo) t; MSPMP100")
ds.Tables(0).TableName =" OBCOP200"
ds.Tables(1).TableName =" MSPMP100" ;
Dim relation As New DataRelation(OBCOP200MSPMP100,ds.Tables(" OBCOP200")。Columns(" prdno"),ds.Tables(" MSPMP100")。Columns( " prdno"),False)
''ds.Relations.Add(" OBCOP200MSPMP100",ds.Tables(" OBCOP200")。Columns(" prdno"),ds.Tables (MSPMP100)。列(" prdno"),True)
ds.Relations.Add(关系)
gridview1.DataSource = ds
gridview1.DataBind()
如果ds.Tables(0).Rows.Count = 0那么
lbl_error.Visible = True
gridview1.Visible = False
否则
lbl_error.Visible = False
gridview1.Visible = True
结束如果
如果ds.Tables(1).Rows.Count = 0那么
lbl_error.Visible = True
gridview1.Visible =错误
否则
lbl_error.Visible = False
gridview1.Visible = True
结束如果
Hi. I have the code working just fine except all the data isn''t coming up with the ds.relations code. Could you see what I''m doing wrong or what else I need to add. Code down below
Dim adapter As OdbcDataAdapter = New OdbcDataAdapter(command)
Dim ds As DataSet = New DataSet()
adapter.SelectCommand = New OdbcCommand("select rmsfiles2.obcop200.line#, rmsfiles2.obcop200.ordno, rmsfiles2.obcop200.quano, rmsfiles2.obcop200.quana, rmsfiles2.obcop200.quans, rmsfiles2.obcop200.c2rdt, rmsfiles2.obcop200.unitm, rmsfiles2.obcop200.actsp, rmsfiles2.obcop200.prdno from rmsfiles2.obcop200 where ordno = " & Order.ToString(), myConnection)
adapter.Fill(ds, "OBCOP200")
adapter.SelectCommand = New OdbcCommand("select rmsfiles2.mspmp100.ptyp1, rmsfiles2.mspmp100.ptyp2, rmsfiles2.mspmp100.descp, rmsfiles2.mspmp100.prdno from rmsfiles2.obcop200 inner join rmsfiles2.mspmp100 on rmsfiles2.obcop200.prdno = rmsfiles2.mspmp100.prdno where rmsfiles2.obcop200.ordno = " & Order.ToString(), myConnection)
adapter.Fill(ds, "MSPMP100")
ds.Tables(0).TableName = "OBCOP200"
ds.Tables(1).TableName = "MSPMP100"
Dim relation As New DataRelation("OBCOP200MSPMP100", ds.Tables("OBCOP200").Columns("prdno"), ds.Tables("MSPMP100").Columns("prdno"), False)
'' ds.Relations.Add("OBCOP200MSPMP100", ds.Tables("OBCOP200").Columns("prdno"), ds.Tables("MSPMP100").Columns("prdno"), True)
ds.Relations.Add(relation)
gridview1.DataSource = ds
gridview1.DataBind()
If ds.Tables(0).Rows.Count = 0 Then
lbl_error.Visible = True
gridview1.Visible = False
Else
lbl_error.Visible = False
gridview1.Visible = True
End If
If ds.Tables(1).Rows.Count = 0 Then
lbl_error.Visible = True
gridview1.Visible = False
Else
lbl_error.Visible = False
gridview1.Visible = True
End If
推荐答案
数据集中缺少哪些列?
Which columns are missing from the dataset?
这篇关于DS。数据集的关系问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!