无数据返回如果nVarChar列上的选择查询的搜索条件仅包含数字 [英] No data return If search condition of a select query on a nVarChar column contains only numerals

查看:63
本文介绍了无数据返回如果nVarChar列上的选择查询的搜索条件仅包含数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows应用程序来同步Windows移动应用程序的Sql CE数据库数据。关于连接到Windows 7 32位PC的移动设备的同步,我遇到了一些问题。



同步时,Windows应用程序会将Sql CE数据库从移动设备复制到PC并进行同步使用本地coppied数据库的数据然后复制回移动设备。如果完成同步的PC是Windows 7 32Bit,那么在使用同步数据库时我会在Windows Mobile应用程序中遇到以下问题。



如果有表使用nVarChar列并对该列执行搜索查询,如果搜索条件包含带单引号的数字以将值指示为字符串,则不会返回任何数据(在以下示例中strProductID是nVarchar列)



例如: -

I have windows application to synchronize Sql CE database data of a windows mobile application. I got few issues on synchronization of mobile connected to windows 7 32bit PC.

On synchronization, windows application will copy Sql CE databse from Mobile Device to the PC and do synchronization of data with locally coppied database then copy back to the Mobile Device. If the PC which done synchronization is a windows 7 32Bit then I''ll get following issues in Windows Mobile Application when working with synchronized database.

If there is a table with nVarChar column and do search query on that column, No data will return if search condition contain numerals with single quotes to indicate value as a string (In following example strProductID is a nVarchar column)

eg:-

SELECT * FROM Products WHERE strProductID='2345'





但是没有引号或带引号的alpha的数字将正常工作



例如: -



But numerals without quotes or alpha with quotes will works fine

eg:-

SELECT * FROM Products WHERE strProductID=2345









or

SELECT * FROM Products WHERE strProductID='asdasd'

推荐答案

试试这个

Try this
SELECT * FROM Products WHERE strProductID = N'2345'



快乐编码!

:)


Happy Coding!
:)


这篇关于无数据返回如果nVarChar列上的选择查询的搜索条件仅包含数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆