首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

VB.NET中sqladapter.fill抛现异常.提示 列无效.

2014-01-28 
VB.NET中sqladapter.fill抛现异常.提示 列无效.我写了一段小程序,发现在程序运行过程中,有异常错误,主要是

VB.NET中sqladapter.fill抛现异常.提示 列无效.我写了一段小程序,发现在程序运行过程中,有异常错误,主要是按照几个字段来查询SQL数据库,combobox里包括字段:编号,姓名,国籍,业绩,加入时间...相对应在SQL中是bh,xm,gj,yj,joindata....各个字段的类型都设置为varchar类型,当使用"姓名"的时候就报错.说列名无效.其中数据库表名为sales
原代码如下


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim id As String = TextBox1.Text
Dim di As String = ComboBox1.Text
Dim constring As String = "Data Source=6FFF157A3A3E49C;Initial Catalog=lzgdb;Integrated Security=True " '定义连接字符串
Dim sqlcon As New SqlClient.SqlConnection(constring) '定义连接
Dim r1 As String = "select * from sales where bh= " & id.ToString '定义combobox中选项的具体意义
Dim r2 As String = "select * from sales where xm= " & id.ToString
Dim r3 As String = "select * from sales where gj= " & id.ToString
Dim r4 As String = "select * from sales where yj= " & id.ToString
Dim r5 As String = "select * from sales where joindate= " & id.ToString
If di = " " Then
MessageBox.Show( "please change item! ")
Else
If id = " " Then         

热点排行