无法使用asp.net中的DataSet读取数据 [英] Can not read data using DataSet in asp.net

查看:68
本文介绍了无法使用asp.net中的DataSet读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经添加了一个DataSet来与我的SQLDatabase连接.测试查询显示正确的值,但是当我以编程方式尝试使用以下代码显示某个字段的值时

dim vrName = dsTest.Tables(tblTest).rows(0).items(0)

syas Tables不是dsTest的成员

请告知我如何像在Winforms中一样使用数据集读取,写入,编辑和删除数据.

非常感谢.

Hi,
I have added a DataSet to connect with my SQLDatabase. Test Query displays correct values but when I programmatically try to display the value of a certain field using following code

dim vrName= dsTest.Tables(tblTest).rows(0).items(0)

it syas Tables is not a member of dsTest

Please advise how can I use dataset to read, write, edit and delete data as we use in winforms.

Thank you very much.

推荐答案

使用数据集进行编码在两个方面都是相同的(ASP.Net/WinForms).根据错误消息,听起来像dsTest不是数据集,而是其他内容.如果将鼠标悬停在dsTest上,Visual Studio应该向您显示您正在使用的类.
Coding with datasets is the same in both worlds (ASP.Net/WinForms). Based on the error message sounds like dsTest isn''t a dataset but something else. If you hover over the dsTest Visual Studio should show you what''s the class you''re using.


您好,kfsehgal,
只需查看以下链接,即可清除您的问题.
数据集类
仍然有任何问题,请向我发送查询.
祝你玩得开心!
Hi kfsehgal,
Just see the following link,it may clears your problem.
Dataset Class
still any problem,send me a query.
Have a good time!!



在C#
Hi,
in C#
 SqlDataAdapter dAdt = new SqlDataAdapter("SELECT * FROM tblTest","ConnectionString" );
            DataSet dSet = new DataSet();
            DataTable dTab = new DataTable();
            DataRow[] dRow;
            dAdt.Fill(dSet, "tblTest");
            dRow = dSet.Tables[0].Rows[0]
string myVar = dSet.Tables[0].Rows[0].ItemArray[0].ToString();



在VB.Net中



in VB.Net

Dim dAdt As New SqlDataAdapter("SELECT * FROM tblTest", "ConnectionString")
Dim dSet As New DataSet()
Dim dTab As New DataTable()
Dim dRow As DataRow()
dAdt.Fill(dSet, "tblTest")
dRow = dSet.Tables(0).Rows(0)
Dim myVar As String = dSet.Tables(0).Rows(0).ItemArray(0).ToString()


这篇关于无法使用asp.net中的DataSet读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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