空单元格查询仅适用于 "LEN(name) > 1 or LEN(name) < 2"
Query with empty cells only works with "LEN(name) > 1 or LEN(name) < 2"
在我的程序 (vb.net) 中,当我使用“LEN(EnterName) > 1 or LEN(EnterName) < 2
”,这很奇怪,因为 > 1 和 <2 只会 select 任何单元格,就像没有 LEN 一样。
如果我不使用 LEN,则会收到此错误消息
"The given transformation is invalid"
这不是唯一的问题。当我使用 LEN 时,它不会 return 我需要的空单元格。
如果你能帮助我,那就太好了。
Picture of Database and vb Application (using LEN) 对不起,为了数据保护,我需要对除这一行以外的任何内容进行像素化。
如果您需要更多信息,请问我!
代码:
Using connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\WE2015_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 - read null value from database
在我的程序 (vb.net) 中,当我使用“LEN(EnterName) > 1 or LEN(EnterName) < 2
”,这很奇怪,因为 > 1 和 <2 只会 select 任何单元格,就像没有 LEN 一样。
如果我不使用 LEN,则会收到此错误消息
"The given transformation is invalid"
这不是唯一的问题。当我使用 LEN 时,它不会 return 我需要的空单元格。
如果你能帮助我,那就太好了。
Picture of Database and vb Application (using LEN) 对不起,为了数据保护,我需要对除这一行以外的任何内容进行像素化。 如果您需要更多信息,请问我!
代码:
Using connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\WE2015_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 - read null value from database