DataTable select criteria with single quotes and without











up vote
-1
down vote

favorite












I have a DataTable dt with Column RefNum. There is a row with RefNum = 293
when i try to retrieve value using dt.Select("RefNum = 293")i get no result , but when i wrap number into single quotes dt.Select("RefNum = '293'") i get result



enter image description here



Could someone explain , how it works ?



other values are fine to read



enter image description here



in database column RefNum is a nvarchar column










share|improve this question




















  • 2




    Sounds like the data type of RefNum is a string type.
    – Crowcoder
    Nov 8 at 13:23










  • @Crowcoder RefNum is nvarchar , but so far others values can be read without quotes . How it possible ?
    – Z.R.T.
    Nov 8 at 13:34










  • @Z.R.T. The nvarchar is string in SQL.
    – S.Akbari
    Nov 8 at 13:35










  • @S.Akbari agree , but how some values from the same column can be retrieved without quotes but others can't. How can you explain different behavior on the pic ?
    – Z.R.T.
    Nov 8 at 13:38








  • 1




    @Z.R.T. if the behaviour is different, it means the types are different. DataTable objects are .NET objects. The column's type will be string not nvarchar. The comparison will follow .NET rules, where comparing objects of different types is false by default. In SQL though, one type is implicitly converted into another and the values compared as if they were the same type
    – Panagiotis Kanavos
    Nov 8 at 14:01















up vote
-1
down vote

favorite












I have a DataTable dt with Column RefNum. There is a row with RefNum = 293
when i try to retrieve value using dt.Select("RefNum = 293")i get no result , but when i wrap number into single quotes dt.Select("RefNum = '293'") i get result



enter image description here



Could someone explain , how it works ?



other values are fine to read



enter image description here



in database column RefNum is a nvarchar column










share|improve this question




















  • 2




    Sounds like the data type of RefNum is a string type.
    – Crowcoder
    Nov 8 at 13:23










  • @Crowcoder RefNum is nvarchar , but so far others values can be read without quotes . How it possible ?
    – Z.R.T.
    Nov 8 at 13:34










  • @Z.R.T. The nvarchar is string in SQL.
    – S.Akbari
    Nov 8 at 13:35










  • @S.Akbari agree , but how some values from the same column can be retrieved without quotes but others can't. How can you explain different behavior on the pic ?
    – Z.R.T.
    Nov 8 at 13:38








  • 1




    @Z.R.T. if the behaviour is different, it means the types are different. DataTable objects are .NET objects. The column's type will be string not nvarchar. The comparison will follow .NET rules, where comparing objects of different types is false by default. In SQL though, one type is implicitly converted into another and the values compared as if they were the same type
    – Panagiotis Kanavos
    Nov 8 at 14:01













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a DataTable dt with Column RefNum. There is a row with RefNum = 293
when i try to retrieve value using dt.Select("RefNum = 293")i get no result , but when i wrap number into single quotes dt.Select("RefNum = '293'") i get result



enter image description here



Could someone explain , how it works ?



other values are fine to read



enter image description here



in database column RefNum is a nvarchar column










share|improve this question















I have a DataTable dt with Column RefNum. There is a row with RefNum = 293
when i try to retrieve value using dt.Select("RefNum = 293")i get no result , but when i wrap number into single quotes dt.Select("RefNum = '293'") i get result



enter image description here



Could someone explain , how it works ?



other values are fine to read



enter image description here



in database column RefNum is a nvarchar column







c# winforms datatable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 13:28

























asked Nov 8 at 13:21









Z.R.T.

1,026511




1,026511








  • 2




    Sounds like the data type of RefNum is a string type.
    – Crowcoder
    Nov 8 at 13:23










  • @Crowcoder RefNum is nvarchar , but so far others values can be read without quotes . How it possible ?
    – Z.R.T.
    Nov 8 at 13:34










  • @Z.R.T. The nvarchar is string in SQL.
    – S.Akbari
    Nov 8 at 13:35










  • @S.Akbari agree , but how some values from the same column can be retrieved without quotes but others can't. How can you explain different behavior on the pic ?
    – Z.R.T.
    Nov 8 at 13:38








  • 1




    @Z.R.T. if the behaviour is different, it means the types are different. DataTable objects are .NET objects. The column's type will be string not nvarchar. The comparison will follow .NET rules, where comparing objects of different types is false by default. In SQL though, one type is implicitly converted into another and the values compared as if they were the same type
    – Panagiotis Kanavos
    Nov 8 at 14:01














  • 2




    Sounds like the data type of RefNum is a string type.
    – Crowcoder
    Nov 8 at 13:23










  • @Crowcoder RefNum is nvarchar , but so far others values can be read without quotes . How it possible ?
    – Z.R.T.
    Nov 8 at 13:34










  • @Z.R.T. The nvarchar is string in SQL.
    – S.Akbari
    Nov 8 at 13:35










  • @S.Akbari agree , but how some values from the same column can be retrieved without quotes but others can't. How can you explain different behavior on the pic ?
    – Z.R.T.
    Nov 8 at 13:38








  • 1




    @Z.R.T. if the behaviour is different, it means the types are different. DataTable objects are .NET objects. The column's type will be string not nvarchar. The comparison will follow .NET rules, where comparing objects of different types is false by default. In SQL though, one type is implicitly converted into another and the values compared as if they were the same type
    – Panagiotis Kanavos
    Nov 8 at 14:01








2




2




Sounds like the data type of RefNum is a string type.
– Crowcoder
Nov 8 at 13:23




Sounds like the data type of RefNum is a string type.
– Crowcoder
Nov 8 at 13:23












@Crowcoder RefNum is nvarchar , but so far others values can be read without quotes . How it possible ?
– Z.R.T.
Nov 8 at 13:34




@Crowcoder RefNum is nvarchar , but so far others values can be read without quotes . How it possible ?
– Z.R.T.
Nov 8 at 13:34












@Z.R.T. The nvarchar is string in SQL.
– S.Akbari
Nov 8 at 13:35




@Z.R.T. The nvarchar is string in SQL.
– S.Akbari
Nov 8 at 13:35












@S.Akbari agree , but how some values from the same column can be retrieved without quotes but others can't. How can you explain different behavior on the pic ?
– Z.R.T.
Nov 8 at 13:38






@S.Akbari agree , but how some values from the same column can be retrieved without quotes but others can't. How can you explain different behavior on the pic ?
– Z.R.T.
Nov 8 at 13:38






1




1




@Z.R.T. if the behaviour is different, it means the types are different. DataTable objects are .NET objects. The column's type will be string not nvarchar. The comparison will follow .NET rules, where comparing objects of different types is false by default. In SQL though, one type is implicitly converted into another and the values compared as if they were the same type
– Panagiotis Kanavos
Nov 8 at 14:01




@Z.R.T. if the behaviour is different, it means the types are different. DataTable objects are .NET objects. The column's type will be string not nvarchar. The comparison will follow .NET rules, where comparing objects of different types is false by default. In SQL though, one type is implicitly converted into another and the values compared as if they were the same type
– Panagiotis Kanavos
Nov 8 at 14:01












1 Answer
1






active

oldest

votes

















up vote
0
down vote













It's very weird that you get results on other tables when searching on string values without quotes. Are you certain these are not numeric columns?



According to docs.microsoft.com/en-us/dotnet/api/system.data.dataview.rowfilter
and www.csharp-examples.net/dataview-rowfilter, filtering on string values/columns requires single quotes.



So I think you better play it safe and use the single quotes.. :-)






share|improve this answer





















  • PS: I cannot see your images, they are blocked by my company's firewall.
    – johey
    Nov 8 at 13:46










  • those aren't images, it's the Microsoft documentation site. If you can't read the docs, you can't write or fix code
    – Panagiotis Kanavos
    Nov 8 at 13:59













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208625%2fdatatable-select-criteria-with-single-quotes-and-without%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













It's very weird that you get results on other tables when searching on string values without quotes. Are you certain these are not numeric columns?



According to docs.microsoft.com/en-us/dotnet/api/system.data.dataview.rowfilter
and www.csharp-examples.net/dataview-rowfilter, filtering on string values/columns requires single quotes.



So I think you better play it safe and use the single quotes.. :-)






share|improve this answer





















  • PS: I cannot see your images, they are blocked by my company's firewall.
    – johey
    Nov 8 at 13:46










  • those aren't images, it's the Microsoft documentation site. If you can't read the docs, you can't write or fix code
    – Panagiotis Kanavos
    Nov 8 at 13:59

















up vote
0
down vote













It's very weird that you get results on other tables when searching on string values without quotes. Are you certain these are not numeric columns?



According to docs.microsoft.com/en-us/dotnet/api/system.data.dataview.rowfilter
and www.csharp-examples.net/dataview-rowfilter, filtering on string values/columns requires single quotes.



So I think you better play it safe and use the single quotes.. :-)






share|improve this answer





















  • PS: I cannot see your images, they are blocked by my company's firewall.
    – johey
    Nov 8 at 13:46










  • those aren't images, it's the Microsoft documentation site. If you can't read the docs, you can't write or fix code
    – Panagiotis Kanavos
    Nov 8 at 13:59















up vote
0
down vote










up vote
0
down vote









It's very weird that you get results on other tables when searching on string values without quotes. Are you certain these are not numeric columns?



According to docs.microsoft.com/en-us/dotnet/api/system.data.dataview.rowfilter
and www.csharp-examples.net/dataview-rowfilter, filtering on string values/columns requires single quotes.



So I think you better play it safe and use the single quotes.. :-)






share|improve this answer












It's very weird that you get results on other tables when searching on string values without quotes. Are you certain these are not numeric columns?



According to docs.microsoft.com/en-us/dotnet/api/system.data.dataview.rowfilter
and www.csharp-examples.net/dataview-rowfilter, filtering on string values/columns requires single quotes.



So I think you better play it safe and use the single quotes.. :-)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 8 at 13:45









johey

11410




11410












  • PS: I cannot see your images, they are blocked by my company's firewall.
    – johey
    Nov 8 at 13:46










  • those aren't images, it's the Microsoft documentation site. If you can't read the docs, you can't write or fix code
    – Panagiotis Kanavos
    Nov 8 at 13:59




















  • PS: I cannot see your images, they are blocked by my company's firewall.
    – johey
    Nov 8 at 13:46










  • those aren't images, it's the Microsoft documentation site. If you can't read the docs, you can't write or fix code
    – Panagiotis Kanavos
    Nov 8 at 13:59


















PS: I cannot see your images, they are blocked by my company's firewall.
– johey
Nov 8 at 13:46




PS: I cannot see your images, they are blocked by my company's firewall.
– johey
Nov 8 at 13:46












those aren't images, it's the Microsoft documentation site. If you can't read the docs, you can't write or fix code
– Panagiotis Kanavos
Nov 8 at 13:59






those aren't images, it's the Microsoft documentation site. If you can't read the docs, you can't write or fix code
– Panagiotis Kanavos
Nov 8 at 13:59




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208625%2fdatatable-select-criteria-with-single-quotes-and-without%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?