C S*_*per 1 .net vb.net asp.net visual-studio-2008
我第一次用 vb.net 编码,想从数据集中读取值。
为此,我编码如下,但不起作用:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'------------------------------Load Name------------------'
Try
Dim strcon As String = ConfigurationManager.ConnectionStrings("ConnStringDb").ConnectionString
Dim i As Integer
Dim con As New SqlConnection(strcon)
da = New SqlDataAdapter("select empName from empMaster_VB", con)
ds = New DataSet()
da.Fill(ds)
For(i=0;i<ds.
Catch ex As Exception
End Try
End Sub
Run Code Online (Sandbox Code Playgroud)
当我们从 C# 中的数据集获取值时,我尝试使用 VB(从 for 循环)作为,
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
int someVar=int.parse(ds.Tables[0].Rows[i][0].toString());
}
Run Code Online (Sandbox Code Playgroud)
但它不能像我上面编码的那样在 vb.net 中工作,
请帮我。
你可以这样试试:
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
Dim someVar As Integer = Integer.parse(ds.Tables(0).Rows(i)(0).toString())
Next
Run Code Online (Sandbox Code Playgroud)
您可以使用在线转换器来解决此问题。