在我的程序(vb.net)中,我只能在有一些单元格空时启动访问 Acces 2000 表的oleDBQuery
,当我使用" LEN(EnterName) > 1 or LEN(EnterName) < 2
"时,这很奇怪,因为 1 和 <2>只会选择任何单元格,就像没有 LEN 一样。
如果我不使用 LEN,则会收到此错误消息
"给定的转换无效"
这不是唯一的问题。当我使用 LEN 时,它不会返回我需要的空单元格。
如果你能帮助我,那就太酷了。
数据库和 vb 应用程序的图片(使用 LEN)我需要像素化任何东西,除了这一行,数据保护的原因。如果您需要更多信息,请问我!
法典:
Using connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:tempWE2015_NEU dura logo.mdb;Persist Security Info=False;")
'fills the combobox with information from the database
'═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
connection.Open() '║
Dim command_Name_Firmen As New OleDbCommand("SELECT Betrieb FROM MaterialHist Where LEN(Betrieb) > 1 or LEN(Betrieb) < 2", connection) '║
Dim reader_Name_Firmen As OleDbDataReader = command_Name_Firmen.ExecuteReader() '║
While reader_Name_Firmen.Read() '║
DatenbankboxDrölf.Items.Add(reader_Name_Firmen.GetString(0)) ''Here in the Brackets is the error if i would not use LEN '║(Datenbankdrölf = Combobox)
End While '║
reader_Name_Firmen.Close() '║
connection.Close() '║
'═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
End Using
似乎您需要正确处理 NULL 值,使用 IsDbNull()
请参阅 vb.net - 从数据库中读取空值