标题:[求助]提示类型不能转换,但是这可是例题呀。
只看楼主
xiaofkg
Rank: 1
等 级:新手上路
威 望:1
帖 子:77
专家分:0
注 册:2007-9-17
得分:0 

我现在把正确的代码贴出来 ,供大家参考
Imports System.Data
Imports System.Data.SqlClient
Partial Class Default2
Inherits System.Web.UI.Page

Protected Sub Page_Load(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) & "<br>"
Next
dtable.AcceptChanges()

gv.DataSource = ds.Tables("test").DefaultView
gv.DataBind()
con.Close()
con = Nothing

End Sub

2007-11-05 15:02
ta8607
Rank: 4
等 级:业余侠客
帖 子:377
专家分:244
注 册:2007-9-22
得分:0 
我晕了!!!!

不理会流言蜚语,努力做好份内事情,只做自己.
2007-11-06 08:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-183170-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.094507 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved