请问dataset1.Tables["aa"].Rows[0][1]中的[0][1]是什么意思呀?

feelsu 2003-10-10 12:21:11
请问Tables["aa"].Rows[0][1]中的[0][1]是什么意思呀?如果我表aa里有个字段item,那我该怎么表示出来呢?
...全文
139 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
isonme 2003-10-10
  • 打赏
  • 举报
回复
第一巷,第二列
wideroad 2003-10-10
  • 打赏
  • 举报
回复
Rows[0][1] 表示第一行,第二列的那个数据
xjwxiong 2003-10-10
  • 打赏
  • 举报
回复
行[從0開始,表示第一行]
列[從0開始,表示第一列]
qqqdong 2003-10-10
  • 打赏
  • 举报
回复
Tables["aa"].Rows[行][列]
Tables["aa"].Rows[行]["item"]
Reeezak 2003-10-10
  • 打赏
  • 举报
回复
说明是取dataset1中,表名为"aa"的表的第1行,第2列
michaelowenii 2003-10-10
  • 打赏
  • 举报
回复
取道aa表的索引为0,1(第一行,第二列)的单元个的值。
xz_king 2003-10-10
  • 打赏
  • 举报
回复 1
Tables["aa"].Rows[0][1]
Rows表示行。
Rows[index] 就是表示index寻行。
Rows[index][index2] 就是表示index行的第index2列。

可以把它当成一个二维数组来理解。
using System;using System.Collections.Generic;using System.Text;using System.Data;using System.Data.SqlClient; namespace DatabaseOperate{ class SqlOperateInfo { //Suppose your ServerName is "aa",DatabaseName is "bb",UserName is "cc", Password is "dd" private string sqlConnectionCommand = "Data Source=aa;Initial Catalog=bb;User ID=cc;Pwd=dd"; //This table contains two columns:KeywordID int not null,KeywordName varchar(100) not null private string dataTableName = "Basic_Keyword_Test"; private string storedProcedureName = "Sp_InertToBasic_Keyword_Test"; private string sqlSelectCommand = "Select KeywordID, KeywordName From Basic_Keyword_Test"; //sqlUpdateCommand could contain "insert" , "delete" , "update" operate private string sqlUpdateCommand = "Delete From Basic_Keyword_Test Where KeywordID = 1"; public void UseSqlReader() { SqlConnection sqlConnection = new SqlConnection(sqlConnectionCommand); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = System.Data.CommandType.Text; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = sqlSelectCommand; sqlConnection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while(sqlDataReader.Read()) { //Get KeywordID and KeywordName , You can do anything you like. Here I just output them. int keywordid = (int)sqlDataReader[0]; //the same as: int keywordid = (int)sqlDataReader["KeywordID"] string keywordName = (string)sqlDataReader[1]; //the same as: string keywordName = (int)sqlDataReader["KeywordName"] Console.WriteLine("KeywordID = " + keywordid + " , KeywordName = " + keywordName); } sqlDataReader.Close(); sqlCommand.Dispose(); sqlConnection.Close(); } public void UseSqlStoredProcedure() { SqlConnection sqlConnection = new SqlConnection(sqlConnectionCommand); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = storedProcedureName; sqlConnection.Open(); sqlCommand.ExecuteNonQuery(); //you can use reader here,too.as long as you modify the sp and let it like select * from .... sqlCommand.Dispose(); sqlConnection.Close(); } public void UseSqlDataSet() { SqlConnection sqlConnection = new SqlConnection(sqlConnectionCommand); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = System.Data.CommandType.Text; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = sqlSelectCommand; sqlConnection.Open(); SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); sqlDataAdapter.SelectCommand = sqlCommand; DataSet dataSet = new DataSet(); //sqlCommandBuilder is for update the dataset to database SqlCommandBuilder sqlCommandBuilder = new SqlCommandBuilder(sqlDataAdapter); sqlDataAdapter.Fill(dataSet, dataTableName); //Do something to dataset then you can update it to Database.Here I just add a row DataRow row = dataSet.Tables[0].NewRow(); row[0] = 10000; row[1] = "new row"; dataSet.Tables[0].Rows.Add(row); sqlDataAdapter.Update(dataSet, dataTableName); sqlCommand.Dispose(); sqlDataAdapter.Dispose(); sqlConnection.Close(); } }}

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧