可能重复:
在访问数据库中将 Null 转换为零
我正在使用 Microsoft Visual Web Developer 2010 Express 创建 ASP/VB.NET 页面以连接 Microsoft Office Access 07。这是我的问题:
我有这个带有三个下拉列表的页面,用于过滤 DataTable,我有这个 Access SQL Query 在 Access 中工作得非常好,但是当我尝试从 VB.net 执行 sql 时,总是出现错误. “表达式中未定义的函数‘Nz’。”
我一直认为可能存在错误,但我仍然找不到解决方案。
VB.NET 代码:
Shared Function SelectFilterWomen(ByVal tTypeCode As Integer, ByVal bBrandCode As Integer, ByVal sSize As Integer) As DataTable
Dim Command As New OleDbCommand()
Command.CommandText = "QUERY;"
Command.Connection = DB.Conn()
Command.Parameters.AddWithValue("@tTypeCode", tTypeCode)
Command.Parameters.AddWithValue("@bBrandCode", bBrandCode)
Command.Parameters.AddWithValue("@sSize", sSize)
Dim Table As New DataTable("FilterWomen Shoes")
Table.Load(Command.ExecuteReader())
Return Table
询问:
SELECT S.sShoes_ID , S.sPicture, S.sSize , S.sPrice
FROM ((Shoes S INNER JOIN Type T ON S.tTypeCode = T.tTypeCode)
INNER JOIN Brand B ON S.bBrandCode = B.bBrandCode)
WHERE S.tTypeCode = Nz(@tTypeCode, T.tTypeCode)
AND S.bBrandCode = Nz(@bBrandCode, B.bBrandCode)
AND S.sSize = Nz(@sSize, S.sSize)
AND S.sSex = 'Female' AND S.sActive = 'Y';
谢谢