最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

DataView.RowFilter的使用(包括in,like等SQL中的操作符)

 更新時間:2011年07月15日 17:13:53   作者:  
這篇blog轉(zhuǎn)自C# examples,對DataView.RowFilter做了詳細(xì)介紹,能像SQL中使用in,like等操作符一樣進(jìn)行過濾查詢,并附有實例,使用方便。

DataView RowFilter Syntax [C#]
This example describes syntax of DataView.RowFil ter expression. It shows how to correctly build expression string (without „SQL injection“) using methods to escape values.

Column names
If a column name contains any of these special characters ~ ( ) # / / = > < + - * % & | ^ ' " [ ], you must enclose the column name within square brackets [ ]. If a column name contains right bracket ] or backslash /, escape it with backslash (/] or //).

[C#]

dataView.RowFilter = "id = 10"; // no special character in column name "id" dataView.RowFilter = "$id = 10"; // no special character in column name "$id" dataView.RowFilter = "[#id] = 10"; // special character "#" in column name "#id" dataView.RowFilter = "[[id/]] = 10"; // special characters in column name "[id]"
Literals
String values are enclosed within single quotes ' '. If the string contains single quote ', the quote must be doubled.

[C#]

dataView.RowFilter = "Name = 'John'" // string value dataView.RowFilter = "Name = 'John ''A'''" // string with single quotes "John 'A'" dataView.RowFilter = String.Format("Name = '{0}'", "John 'A'".Replace("'", "''"));
Number values are not enclosed within any characters. The values should be the same as is the result of int.ToString() or float.ToString() method for invariant or English culture.

[C#]

dataView.RowFilter = "Year = 2008" // integer value dataView.RowFilter = "Price = 1199.9" // float value dataView.RowFilter = String.Format(CultureInfo.InvariantCulture.NumberFormat, "Price = {0}", 1199.9f);
Date values are enclosed within sharp characters # #. The date format is the same as is the result of DateTime.ToString() method for invariant or English culture.

[C#]

dataView.RowFilter = "Date = #12/31/2008#" // date value (time is 00:00:00) dataView.RowFilter = "Date = #2008-12-31#" // also this format is supported dataView.RowFilter = "Date = #12/31/2008 16:44:58#" // date and time value dataView.RowFilter = String.Format(CultureInfo.InvariantCulture.DateTimeFormat, "Date = #{0}#", new DateTime(2008, 12, 31, 16, 44, 58));
Alternatively you can enclose all values within single quotes ' '. It means you can use string values for numbers or date time values. In this case the current culture is used to convert the string to the specific value.

[C#]

dataView.RowFilter = "Date = '12/31/2008 16:44:58'" // if current culture is English dataView.RowFilter = "Date = '31.12.2008 16:44:58'" // if current culture is German dataView.RowFilter = "Price = '1199.90'" // if current culture is English dataView.RowFilter = "Price = '1199,90'" // if current culture is German
Comparison operators
Equal, not equal, less, greater operators are used to include only values that suit to a comparison expression. You can use these operators = <> < <= > >=.

Note: String comparison is culture-sensitive, it uses CultureInfo from DataTable.Locale property of related table (dataView.Table.Locale). If the property is not explicitly set, its default value is DataSet.Locale (and its default value is current system culture Thread.Curren tThread.Curren tCulture).

[C#]

dataView.RowFilter = "Num = 10" // number is equal to 10 dataView.RowFilter = "Date < #1/1/2008#" // date is less than 1/1/2008 dataView.RowFilter = "Name <> 'John'" // string is not equal to 'John' dataView.RowFilter = "Name >= 'Jo'" // string comparison
Operator IN is used to include only values from the list. You can use the operator for all data types, such as numbers or strings.

[C#]

dataView.RowFilter = "Id IN (1, 2, 3)" // integer values dataView.RowFilter = "Price IN (1.0, 9.9, 11.5)" // float values dataView.RowFilter = "Name IN ('John', 'Jim', 'Tom')" // string values dataView.RowFilter = "Date IN (#12/31/2008#, #1/1/2009#)" // date time values dataView.RowFilter = "Id NOT IN (1, 2, 3)" // values not from the list
Operator LIKE is used to include only values that match a pattern with wildcards. Wildcard character is * or %, it can be at the beginning of a pattern '*value', at the end 'value*', or at both '*value*'. Wildcard in the middle of a patern 'va*lue' is not allowed.

[C#]

dataView.RowFilter = "Name LIKE 'j*'" // values that start with 'j' dataView.RowFilter = "Name LIKE '%jo%'" // values that contain 'jo' dataView.RowFilter = "Name NOT LIKE 'j*'" // values that don't start with 'j'
If a pattern in a LIKE clause contains any of these special characters * %

相關(guān)文章

  • ASP.NET?MVC實現(xiàn)本地化和全球化

    ASP.NET?MVC實現(xiàn)本地化和全球化

    這篇文章介紹了ASP.NET?MVC實現(xiàn)本地化和全球化的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-10-10
  • 基于ASP.NET+easyUI框架實現(xiàn)圖片上傳功能(表單)

    基于ASP.NET+easyUI框架實現(xiàn)圖片上傳功能(表單)

    這篇文章主要介紹了基于ASP.NET+easyUI框架實現(xiàn)圖片上傳功能的相關(guān)資料,需要的朋友可以參考下
    2016-06-06
  • ASP.NET Cookie是怎么生成的(推薦)

    ASP.NET Cookie是怎么生成的(推薦)

    這篇文章主要介紹了ASP.NET Cookie是怎么生成的,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-01-01
  • asp.net url傳遞后地址欄亂碼(中文超過兩個漢字)

    asp.net url傳遞后地址欄亂碼(中文超過兩個漢字)

    asp.net 頁面?zhèn)髦形某^兩個漢字后面就亂碼,編碼編好的url是正確的,可傳到另一個頁面就會出錯,在地址欄就已經(jīng)亂碼了,本文介紹詳細(xì)的解決方法,感興趣的朋友可以了解下,或許對你學(xué)習(xí)asp.net有所幫助
    2013-02-02
  • ASP.NET MVC5網(wǎng)站開發(fā)修改及刪除文章(十)

    ASP.NET MVC5網(wǎng)站開發(fā)修改及刪除文章(十)

    這篇文章主要為大家詳細(xì)介紹了ASP.NET MVC5網(wǎng)站開發(fā)修改及刪除文章,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2015-09-09
  • .Net實現(xiàn)延遲隊列

    .Net實現(xiàn)延遲隊列

    這篇文章介紹了.Net實現(xiàn)延遲隊列的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-07-07
  • asp.net實現(xiàn)拒絕頻繁的IP訪問的方法

    asp.net實現(xiàn)拒絕頻繁的IP訪問的方法

    這篇文章主要介紹了asp.net實現(xiàn)拒絕頻繁的IP訪問的方法,涉及asp.net針對訪問IP的判斷及配置文件的設(shè)置技巧,需要的朋友可以參考下
    2016-04-04
  • Asp.Net用OWC操作Excel的實例代碼

    Asp.Net用OWC操作Excel的實例代碼

    這篇文章介紹了Asp.Net用OWC操作Excel的實例代碼,有需要的朋友可以參考一下,希望對你有所幫助
    2013-07-07
  • WPF實現(xiàn)左右移動(晃動)動畫效果

    WPF實現(xiàn)左右移動(晃動)動畫效果

    這篇文章主要為大家詳細(xì)介紹了WPF實現(xiàn)左右移動或晃動動畫效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • 基于ABP架構(gòu)開發(fā)的.Net Core項目部署到IIS問題匯總

    基于ABP架構(gòu)開發(fā)的.Net Core項目部署到IIS問題匯總

    這篇文章介紹了基于ABP架構(gòu)開發(fā)的.Net Core項目部署到IIS問題匯總,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06

最新評論

马关县| 江都市| 松原市| 枣阳市| 大竹县| 定陶县| 广河县| 裕民县| 乐陵市| 武穴市| 沧源| 德昌县| 兴文县| 汶上县| 新源县| 乐山市| 额济纳旗| 泽普县| 永善县| 鄂伦春自治旗| 西盟| 广水市| 黔西县| 青铜峡市| 陆川县| 遂宁市| 巴彦淖尔市| 都安| 江永县| 昭平县| 拉萨市| 文山县| 万源市| 绥德县| 延吉市| 河津市| 乌鲁木齐县| 梧州市| 辽源市| 鲜城| 麻栗坡县|