当前位置: 代码迷 >> SQL >> VB.NET中sqladapter.fill抛现错误.提示 列无效.
  详细解决方案

VB.NET中sqladapter.fill抛现错误.提示 列无效.

热度:383   发布时间:2016-05-05 13:04:16.0
VB.NET中sqladapter.fill抛现异常.提示 列无效.
点击右边红色标题查看本文完整版: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     

  相关解决方案