求把一段简单的VB翻译成C#
<%
Dim s As Integer
Dim V(1000) As String
V = Split(ds.Tables(0).Rows(i)(2), ",")
Dim conn7 As Data.SqlClient.SqlConnection
conn7 = New System.Data.SqlClient.SqlConnection
conn7.ConnectionString = checkname.sjkconn1()
conn7.Open()
Dim sql7 As Data.SqlClient.SqlCommand
sql7 = New System.Data.SqlClient.SqlCommand
For s = 0 To UBound(V)
sql7.CommandText = "select * from [restaurantslb] with (nolock) where id=" & V(s) & ""
sql7.Connection = conn7
Dim rs7 As System.Data.SqlClient.SqlDataReader
rs7 = sql7.ExecuteReader
If rs7.Read() Then
%>
<td width="10%"><%=rs7(2)%></td>
<%
End If
rs7.Close()
Next
sql7.Cancel()
conn7.Close()
conn7 = Nothing
%>
<td width="10%"><%=ds.Tables(0).Rows(i)("tj")%></td>
<td width="20%">
<%If ds.Tables(0).Rows(i)("tj") = "否" Then%>
<a href="restaurants_tj.aspx?id=<%=ds.Tables(0).Rows(i)(0)%>">推荐</a>
<%else%>
<a href="restaurants_tj.aspx?id=<%=ds.Tables(0).Rows(i)(0)%>">取消推荐</a>
<%end if%> |
<a href="restaurantspic_list.aspx?id=<%=ds.Tables(0).Rows(i)(0)%>&hid=<%=ds.Tables(0).Rows(i)(0)%>">Photos</a>
| <a href="restaurants_edit.aspx?id=<%=ds.Tables(0).Rows(i)(0)%>">编辑</a>
| <a href="restaurants_del.aspx?id=<%=ds.Tables(0).Rows(i)(0)%>" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
</tr>
<%
Next
ds.clear
ds.dispose
da.dispose
End If
conn.Close()
conn = Nothing
%>
vb c# 求翻写
[解决办法]
<%
int s = 0;
string[] V = new string[1001];
V = ds.Tables(0).Rows[i][2].Split(',');
Data.SqlClient.SqlConnection conn7 = null;
conn7 = new System.Data.SqlClient.SqlConnection();
conn7.ConnectionString = checkname.sjkconn1();
conn7.Open();
Data.SqlClient.SqlCommand sql7 = null;
sql7 = new System.Data.SqlClient.SqlCommand();
for (s = 0; s <= V.GetUpperBound(0); s++)
{
sql7.CommandText = "select * from [restaurantslb] with (nolock) where id=" + V[s] + "";
sql7.Connection = conn7;
System.Data.SqlClient.SqlDataReader rs7 = null;
rs7 = sql7.ExecuteReader();
if (rs7.Read())
{
%>
<td width="10%"><%=rs7[2]%></td>
<%
}
rs7.Close();
}
sql7.Cancel();
conn7.Close();
conn7 = null;
%>
<td width="10%"><%=ds.Tables(0).Rows[i]["tj"]%></td>
<td width="20%">
<%If ds.Tables(0).Rows(i)("tj") = "否" Then%>
<a href="restaurants_tj.aspx?id=<%=ds.Tables(0).Rows[i][0]%>">推荐</a>
<%else%>
<a href="restaurants_tj.aspx?id=<%=ds.Tables(0).Rows[i][0]%>">取消推荐</a>
<%end if%>
[解决办法]
<a href="restaurantspic_list.aspx?id=<%=ds.Tables(0).Rows[i][0]%>&hid=<%=ds.Tables(0).Rows[i][0]%>">Photos</a>
[解决办法]
<a href="restaurants_edit.aspx?id=<%=ds.Tables(0).Rows[i][0]%>">编辑</a>
[解决办法]
<a href="restaurants_del.aspx?id=<%=ds.Tables(0).Rows[i][0]%>" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
</tr>
<%
Next;
ds.Clear();
ds.Dispose();
da.Dispose();
}
conn.Close();
conn = null;
%>