{vb}数据哭代码:
create database Sql
create table Vote
(
voteID int Primary KEY,
voteName varchar(100) not null,
voteNumber int not null,
)
select * from vote
insert into vote values(1,'孙小明',0)
insert into vote values(2,'程放',0)
insert into vote values(3,'王历历',0)
asp.net vb 代码
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsCallback = False Then
Dim con As New SqlConnection("server=.;database=sql;uid=sa;pwd=;")
Dim com As SqlCommand = New SqlCommand
com.CommandText = "select voteid,votename from vote"
com.Connection = con
con.Open()
Dim a As SqlDataReader
a = com.ExecuteReader
Me.rBtnitem.DataSource = a
Me.rBtnitem.DataTextField = "votename"
Me.rBtnitem.DataValueField = "voteid"
Me.rBtnitem.DataBind()
End If
End Sub
程序出错:
“/WebSite6”应用程序中的服务器错误。
--------------------------------------------------------------------------------
对象名 'vote' 无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 对象名 'vote' 无效。
源错误:
行 11: con.Open()
行 12: Dim a As SqlDataReader
行 13: a = com.ExecuteReader
行 14: Me.rBtnitem.DataSource = a
行 15: Me.rBtnitem.DataTextField = "votename"
请高手帮帮忙.....