data.rows(index)不起作用 [英] data.rows(index) not working
本文介绍了data.rows(index)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请参阅代码. data.Rows(index)无法正常工作,出现类似以下错误:
不能像一种方法一样使用.请帮忙
please see the code. data.Rows(index) is not working there is an error like:
can''t be used like a method. Please help
string article_visit="0";
SqlConnection con=Database.GetConnection();
DataTable data=new DataTable();
SqlCommand sqlQuery=new SqlCommand("seelct * from category where article_allow = 1", con);
SqlDataAdapter dataAdapter=new SqlDataAdapter(sqlQuery);
//Dim dataAdapter As New OdbcDataAdapter(sqlQuery, connectionString)
dataAdapter.Fill(data);
//Dim index As Integer = 0
int index=0;
do
{
article_visit="0";
SqlCommand cmd=new SqlCommand("SELECT article_visit FROM article_list where cat_ID=" & data.Rows(index)("cat_ID") & " and article_status=1",con);
dataAdapter=new SqlDataAdapter(cmd);
DataTable data1=new DataTable();
dataAdapter.Fill(data1);
int index1=0;
do
{
article_visit=int.Parse(data1.Rows(index1)("article_visit")) + article_visit;
index1=index1+1;
}while(index1<data1.Rows.Count);
index=index+1;
}while(index<data.Rows.Count);
[edit]已添加代码块-OriginalGriff [/edit]
[edit]Code block added - OriginalGriff[/edit]
推荐答案
用大括号替换括号:C#中的数组使用"["和"]''不是``(''和'')''
Replace the braces with square brackets: Arrays in C# are accessed with ''['' and '']'' not ''('' and '')''
SqlCommand cmd=new SqlCommand("SELECT article_visit FROM article_list where cat_ID=" & data.Rows[index]["cat_ID"] & " and article_status=1",con);
这篇关于data.rows(index)不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文