日期:2014-05-18  浏览次数:20452 次

初学者请教DataSet数据集的问题
今天我学习到了使用VS DataSet建立数据访问逻辑层,利用VS建立了一个名为authorsTableAdapter的数据集,有个例程代码如下:
<%@ Page Language="VB" %>
<%@ Import Namespace ="DataSetTableAdapters" %>
<%@ Import Namespace ="DataSet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  Dim authorsAdapter As New authorsTableAdapter
  Dim authorsTable As authorsDataTable
  authorsTable = authorsAdapter.GetAuthors()
  Response.Write(authorsTable.Item(0).au_id)
  End Sub
</script>
我想把其转为C#语言的,在出错信息提示:using 命名空间指令只能应用于命名空间;“DataSet”是一个类型,而不是命名空间,我后来将其它改为如下代码,还有最后一句不会写了,是否正常,不正确的话,应该怎么写,第四句应该怎么改。
修改代码如下:
<%@ Page Language="C#" %>
<%@ Import Namespace ="DataSetTableAdapters" %>
此处应该如何引用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  protected void Page_Load(object sender, EventArgs e)
  {
  authorsTableAdapter authorsAdapter=new authorsTableAdapter() ;
  DataSet.authorsDataTable authorsTable =new DataSet.authorsDataTable ();这么定义可以吗,编译器倒是通过了
  authorsTable = authorsAdapter.GetAuthors();
  //Response.Write(authorsTable.); 这句输出应该如何写
  }
</script>

------解决方案--------------------
authorsTable[0].Rows[0].ItemArray[0]