DS。数据集的关系问题 [英] ds. relations problem with dataset

查看:72
本文介绍了DS。数据集的关系问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我的代码工作得很好,除了所有数据都没有提供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

推荐答案

代码看起来不错。你又得到了什么错误?
The code looks alright to me. What''s the error you''re getting again?


这就是我没有得到任何错误我没有从表中获得我需要的3列
thats the thing I''m not getting no error I''m not getting 3 columns that I need from the table

代码看起来不错。你又得到了什么错误?
The code looks alright to me. What''s the error you''re getting again?



这就是我没有得到的错误我没有得到3列我需要从表
thats the thing I''m not getting no error I''m not getting 3 columns that I need from the table



数据集中缺少哪些列?

Which columns are missing from the dataset?


这篇关于DS。数据集的关系问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆