Imports System.Data
Imports System.Data.SqlClient
Partial Class datatable
Inherits System.Web.UI.Page
Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim con As SqlConnection
Dim str As String
Dim ds As New DataSet
Dim coldrow As DataRowCollection
Dim drow As DataRow
Dim init As Integer
str = "Data Source=.;Initial Catalog=sheet;Integrated Security=true;"
con = New SqlConnection(str)
con.Open()
Dim ada As New SqlDataAdapter("select * from test", con)
ada.Fill(ds, "test")
Dim dtable As New datatable
dtable = ds.Tables("test")
coldrow = dtable.rows
For init = 0 To coldrow.Count - 1
drow = coldrow.Item(init)
lbl.Text = lbl.Text & "id" & drow(0)
lbl.Text = lbl.Text & "dealer" & drow(1)
lbl.Text = lbl.Text & "areaBig" & drow(2)
lbl.Text = lbl.Text & "areaSmall" & drow(3)
Next
gv.DataSource = ds.Tables("test").DefaultView
gv.DataBind()
con.Close()
con = Nothing
lbl.Text = lbl.Text & "查找成功"
End Sub
End Class
为什么总是提示错误 1 类型“System.Data.DataTable”的值无法转换为“datatable”。
错误 2 “rows”不是“datatable”的成员。 请各位看看。。。