System.Data.SqlClient.SqlException: 列名 '计算机科学系' 无效。 20

ImportsSystem.DataImportsSystem.Data.SqlClient'导入使用SQLSERVER数据库的命名空间PartialClassstu_D... Imports System.Data
Imports System.Data.SqlClient '导入使用SQL SERVER 数据库的命名空间
Partial Class stu_Default2
Inherits System.Web.UI.Page

Protected Sub DpUName_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DpUName.SelectedIndexChanged
Dim ConStr As String ''与数据库连接的语句.
ConStr = "Data Source=localhost; Initial Catalog=data; Persist Security Info=False; Integrated Security=SSPI"
Dim SqlStr As String
SqlStr = "Select distinct [tname] from keti where xibie=DpUName.SelectedValue"
Dim Da As New SqlDataAdapter(SqlStr, ConStr)
Dim Ds As New DataSet
Dim MyTable As New DataTable

Da.Fill(Ds, "keti")
MyTable = Ds.Tables(0)
If MyTable.Rows.Count <> 0 Then
DpU1Name.DataSource = MyTable
DpU1Name.DataTextField = "tname"
DpU1Name.DataBind()
End If
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ConStr As String ''与数据库连接的语句.
ConStr = "Data Source=localhost; Initial Catalog=data; Persist Security Info=False; Integrated Security=SSPI"
Dim SqlStr As String
SqlStr = "Select distinct [xibie] from keti"
Dim Da As New SqlDataAdapter(SqlStr, ConStr)
Dim Ds As New DataSet
Dim MyTable As New DataTable

Da.Fill(Ds, "keti")
MyTable = Ds.Tables(0)
If MyTable.Rows.Count <> 0 Then
DpUName.DataSource = MyTable
DpUName.DataTextField = "xibie"
DpUName.DataBind()
End If
Dim ConStr1 As String ''与数据库连接的语句.
ConStr1 = "Data Source=localhost; Initial Catalog=data; Persist Security Info=False; Integrated Security=SSPI"
Dim SqlStr1 As String
SqlStr1 = "Select distinct [tname] from keti where xibie=" + Me.DpUName.SelectedValue
Dim Da1 As New SqlDataAdapter(SqlStr1, ConStr1)
Dim Ds1 As New DataSet
Dim MyTable1 As New DataTable

Da1.Fill(Ds1, "keti")
MyTable1 = Ds1.Tables(0)
If MyTable1.Rows.Count <> 0 Then
DpU1Name.DataSource = MyTable1
DpU1Name.DataTextField = "tname"
DpU1Name.DataBind()
End If
End Sub
End Class
运行时,提示System.Data.SqlClient.SqlException: 列名 '计算机科学系' 无效。
注:”计算机科学系“ 是xibie字段中的一类容。
展开
 我来答
S苦尽甘来S
2009-05-18 · TA获得超过144个赞
知道答主
回答量:218
采纳率:0%
帮助的人:107万
展开全部
更新试试
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式