DataSet读取数据时,有出错,请帮忙看看!
DataSet读取数据时,有出错,
代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data.Sql;
namespace ConsoleDataSetTest
{
class Program
{
static void Main(string[] args)
{
SqlConnection thisConnection = new SqlConnection(@"Data Source=WONDER_TAN_XP00;Initial Catalog=product;Persist Security Info=True;User ID=sa;Password=123");
SqlDataAdapter thisAdapter = new SqlDataAdapter("select * from userss",thisConnection);
productDataSet thisDataSet = new productDataSet();
thisAdapter.Fill(thisDataSet,"userss");
foreach (DataRow theRow in thisDataSet.Tables["userss"].Rows)
{
Console.WriteLine(theRow["id"]+"\t"+theRow["name"]);
}
}
}
}
出错的信息是如下:
Error 1 The type or namespace name 'DataRow' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\agan_qin\My Documents\Visual Studio 2005\Projects\ConsoleDataSetTest\ConsoleDataSetTest\Program.cs 20 22 ConsoleDataSetTest
Error 2 Cannot apply indexing with [] to an expression of type 'DataRow' C:\Documents and Settings\agan_qin\My Documents\Visual Studio 2005\Projects\ConsoleDataSetTest\ConsoleDataSetTest\Program.cs 22 35 ConsoleDataSetTest
Error 3 Cannot apply indexing with [] to an expression of type 'DataRow' C:\Documents and Settings\agan_qin\My Documents\Visual Studio 2005\Projects\ConsoleDataSetTest\ConsoleDataSetTest\Program.cs 22 53 ConsoleDataSetTest