我有此代码:
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
' retrieving the administration table.
con.Open()
DataAdapter1.SelectCommand = sqladmin
DataAdapter1.Fill(ds, "stratos")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "stratos"
con.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Retrieving Administration Table: " & myerror.Message)
End Try
Try
' retrieving the projects list.
con.Open()
DataAdapter2.SelectCommand = sqlprojects
DataAdapter2.Fill(ds2, "projects")
ListBox1.Items.Clear()
For Each DataRow In ds2.Tables("projects").Rows
' ##### THE ERROR OCCURS ON THE LINE BELOW: ##### '
ListBox1.Items.Add(DataRow("project_name"))
Next
con.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Retrieving Projects List: " & myerror.Message)
End Try
和即时通讯收到以下错误:
我在运行Windows 7 OS的网关笔记本电脑上使用Visual Basic 2010 Express
我该如何解决此错误?
最佳答案
您将需要将带有错误的循环更改为以下内容:
For Each dr as DataRow In ds2.Tables("projects").Rows
' ##### THE ERROR OCCURS ON THE LINE BELOW: ##### '
ListBox1.Items.Add(Convert.ToString(dr("project_name")))
Next
关于vb.net - 如何在vb.net中将后期绑定(bind)语法转换为早期绑定(bind)语法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7302935/