问题描述
大家好,我尝试使用visual basic 2010在webforms ASP中读取表MS访问数据,但这显示以下错误。有人你可能会帮忙。
错误信息条件表达式中的数据类型不匹配。
这里是代码:
受保护的子btnbuscar1_Click(ByVal发送者为对象,ByVal e As EventArgs)处理btnbuscar1.Click
尝试
Dim con As String = Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\ Users\luis.valdez\Documents\info.accdb
conConexion = New OleDb .OleDbConnection(con)
Catch ex As Exception
MsgBox(错误al conectarse)
结束尝试
Dim lista As Byte
Dim str As String
如果txtIdcaso.Text那么
conConexion.Open()
str = SELECT * FROM Casos_Tbl WHERE(IDCaso ='& txtIdcaso.Text&')
'Dim cmd As OleDbCommand = New OleDbCommand(str,co nConexion)
adaptador =新OleDb.OleDbDataAdapter(str,conConexion)
registro =新数据集
adaptador.Fill(registro,Casos_Tbl )
lista = registro.Tables(Casos_Tbl)。Rows.Count
Else
MsgBox(Debe Ingresar un codigo。, vbExclamation,UTCtickets)
结束如果
如果lista = 0那么
lblidcase.Text = registro.Tables(Casos_Tbl)。行(0).Item(IDCaso)
txtuser.Text = registro.Tables(Casos_Tbl)。行(0).Item(Usuario)
txtarea.Text = registro.Tables(Casos_Tbl)。行(0).Item(Area)
lblDate.Text = registro.Tables(Casos_Tbl)。行(0) .Item(FechayHora)
Dropcateg.Text = registro.Tables(Casos_Tbl)。行(0).Item(Categoria)
LblSev1.Text = registro.Tables(Casos_Tbl)。行(0).Item(Severidad)
dropstat.Text = registro.Tables(Casos_Tbl)。行(0).Item(状态)
txtdescort.Text = registro.Tables(Casos_Tbl)。行(0).Item(DescripcionCorta)
txtdescdetall.Text = registro.Tables(Casos_Tbl)。行(0).Item(DescripcionDetallada)
结束如果
txtIdcaso.Focus()
结束Sub
Hi everyone, i'am trying read the data from a table MS acces in a webforms ASP with visual basic 2010, but this show the following error. someone you maybe helpme.
Error Message "Data type mismatch in criteria expression."
here's the code:
Protected Sub btnbuscar1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnbuscar1.Click
Try
Dim con As String = Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\luis.valdez\Documents\info.accdb
conConexion = New OleDb.OleDbConnection(con)
Catch ex As Exception
MsgBox("Error al conectarse")
End Try
Dim lista As Byte
Dim str As String
If txtIdcaso.Text Then
conConexion.Open()
str = SELECT * FROM Casos_Tbl WHERE (IDCaso = '" & txtIdcaso.Text & "')"
'Dim cmd As OleDbCommand = New OleDbCommand(str, conConexion)
adaptador = New OleDb.OleDbDataAdapter(str, conConexion)
registro = New DataSet
adaptador.Fill(registro, "Casos_Tbl")
lista = registro.Tables("Casos_Tbl").Rows.Count
Else
MsgBox("Debe Ingresar un codigo.", vbExclamation, "UTCtickets")
End If
If lista = 0 Then
lblidcase.Text = registro.Tables("Casos_Tbl").Rows(0).Item("IDCaso")
txtuser.Text = registro.Tables("Casos_Tbl").Rows(0).Item("Usuario")
txtarea.Text = registro.Tables("Casos_Tbl").Rows(0).Item("Area")
lblDate.Text = registro.Tables("Casos_Tbl").Rows(0).Item("FechayHora")
Dropcateg.Text = registro.Tables("Casos_Tbl").Rows(0).Item("Categoria")
LblSev1.Text = registro.Tables("Casos_Tbl").Rows(0).Item("Severidad")
dropstat.Text = registro.Tables("Casos_Tbl").Rows(0).Item("Status")
txtdescort.Text = registro.Tables("Casos_Tbl").Rows(0).Item("DescripcionCorta")
txtdescdetall.Text = registro.Tables("Casos_Tbl").Rows(0).Item("DescripcionDetallada")
End If
txtIdcaso.Focus()
End Sub
推荐答案
这篇关于ASP.NET VB2010上的条件表达式中的数据类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!