Thomas’ Developer Blog

May 29, 2011

Checking if executescalar returns a result in VB.Net

Filed under: .Net Framework 3.5, Asp.Net Framework 2.0, sql, vb.net — sanzon @ 6:01 pm

Yea, it’s been over a year since I updated this blog, but spending 15-20 minutes finding a solution to something so simple got a bit annoying so here’s the solution for future searchers!

If you run executescalar it returns the first column/result. The problem is if you don’t have a result it returns nothing.

Keyword: nothing

Yes you’re working with a database so you would assume it’s DBNull, but if there is an empty table SQL is not going to return DBNull, but will return nothing.

Solution:

Dim sqlResult as object = sqlCMD.executescalar()

if sqlResult is nothing then
‘ No result found
else
sqlResult.tostring   ‘result found
end if

Simple!

Advertisements

61 Comments »

  1. Excuse, the phrase is removed

    By the way, what do you think about this icons site?

    Comment by png icons — September 13, 2012 @ 1:12 pm

  2. I love what you guys are up too. This type of clever work
    and exposure! Keep up the good works guys I’ve
    you guys to my own blogroll.

    Comment by how to configure best cable the best modem for xbox live — August 8, 2014 @ 9:10 pm

  3. This article provides clear idea designed for the new visitors of blogging,
    that genuinely how to do running a blog.

    Comment by how to configure best cable do you i need a modem for — August 9, 2014 @ 4:41 am

  4. of course like your web site but you have to test the spelling on quite a few of your
    posts. Many of them are rife with spelling issues and I in finding it
    very troublesome to tell the reality on the other hand I’ll certainly come again again.

    Comment by how to configure best buy fastest cable modem for comcast — August 14, 2014 @ 3:15 am

  5. Hello to all, for the reason that I am really eager
    of reading this blog’s post to be updated on a regular basis.
    It carries good stuff.

    Comment by how to configure best comcast best best cable modem for — August 14, 2014 @ 9:49 pm

  6. Hello to every , as I am actually eager of reading this blog’s post to be updated
    regularly. It contains fastidious data.

    Comment by how to configure arris cable modem for comcast internet — August 21, 2014 @ 12:57 pm

  7. If you desire to take a good deal from this paragraph then you have to apply such strategies to your won web site.

    Comment by how to configure best best docsis 3 motorola cable modem for — August 31, 2014 @ 3:53 pm

  8. What’s up to every one, the contents existing at this site are
    genuinely awesome for people knowledge, well, keep up the nice
    work fellows.

    Comment by how to configure adsl adsl modem for bsnl broadband — September 1, 2014 @ 11:04 pm

  9. I tend not to comment, however after looking at through a bunch of remarks here Checking if executescalar returns a result in VB.Net |
    Thomas’ Developer Blog. I actually do have a few questions for you if you do not mind.

    Could it be simply me or does it look as if like some of the comments
    appear as if they are coming from brain dead visitors?

    :-P And, if you are posting on additional online social sites,
    I’d like to follow anything new you have to post.
    Would you list of every one of all your social community sites like your linkedin profile,
    Facebook page or twitter feed?

    Comment by how to configure dlink adsl modem for bsnl broadband — September 4, 2014 @ 4:56 pm

  10. I know this site presents quality dependent
    articles or reviews and other material, is there any other
    website which presents these kinds of things in quality?

    Comment by how to configure best arris fastest cable modem for comcast — September 5, 2014 @ 2:01 am

  11. Thanks for finally writing about >Checking if executescalar
    returns a result in VB.Net | Thomas’ Developer Blog
    <Liked it!

    Comment by how to configure best comcast best cable modem for mediacom — September 6, 2014 @ 1:54 am

  12. I loved as much as you will receive carried out right here.
    The sketch is attractive, your authored subject matter stylish.
    nonetheless, you command get got an edginess over that you wish be delivering
    the following. unwell unquestionably come more formerly again since exactly the same nearly a
    lot often inside case you shield this increase.

    Comment by how to configure best best best modem for xbox live — September 7, 2014 @ 2:45 pm

  13. I am really glad to glance at this web site posts which carries plenty of helpful data,
    thanks for providing these kinds of data.

    Comment by how to configure best best wireless fastest cable modem for comcast — September 8, 2014 @ 6:52 am

  14. Hello There. I found your blog using msn. This is a really well written article.
    I’ll be sure to bookmark it and return to read more of your useful
    info. Thanks for the post. I will definitely return.

    Comment by how to configure best comcast best best cable modem for — September 8, 2014 @ 9:49 am

  15. I have been exploring for a little for any high quality articles or blog posts in this
    sort of house . Exploring in Yahoo I finally stumbled upon this website.

    Reading this information So i’m satisfied to convey that I have an incredibly
    excellent uncanny feeling I came upon exactly what
    I needed. I most definitely will make sure to don?t overlook this
    website and give it a look regularly.

    Comment by how to configure best best cable the best modem for xbox — September 9, 2014 @ 1:33 pm

  16. There’s certainly a great deal to know about this topic.

    I like all the points you’ve made.

    Comment by how to configure arris wireless cable modem for — September 11, 2014 @ 12:42 pm

  17. Thanks on your marvelous posting! I certainly enjoyed reading it, you might be a great author.I will remember to
    bookmark your blog and will come back very soon. I want to encourage you
    to ultimately continue your great work, have a nice holiday weekend!

    Comment by how to configure best cable best cable modem for mac — September 11, 2014 @ 11:06 pm

  18. Hello i am kavin, its my first occasion to commenting anyplace, when i read this post i thought i could also create comment due to this brilliant piece of writing.

    Comment by how to configure best comcast dsl the best modem for xbox — September 12, 2014 @ 11:11 am

  19. Great beat ! I wish to apprentice while you amend your
    website, how could i subscribe for a blog site? The account aided
    me a acceptable deal. I had been a little bit acquainted
    of this your broadcast provided bright clear idea

    Comment by how to configure best best docsis 3 fastest cable modem for comcast — September 14, 2014 @ 11:22 am

  20. Hey! I know this is kinda off topic but I was wondering if you knew where I could get a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having problems
    finding one? Thanks a lot!

    Comment by how to configure best comcast how to configure modem zyxel — September 17, 2014 @ 1:07 am

  21. Attractive component of content. I simply stumbled upon your web
    site and in accession capital to claim that I get actually loved account
    your blog posts. Any way I will be subscribing
    in your augment or even I achievement you access constantly fast.

    Comment by how to configure best best dsl do you need a modem for — September 17, 2014 @ 11:47 am

  22. I know this if off topic but I’m looking into starting my own blog and was curious
    what all is needed to get set up? I’m assuming having a
    blog like yours would cost a pretty penny? I’m not very internet
    savvy so I’m not 100% sure. Any recommendations or advice would be greatly appreciated.
    Many thanks

    Comment by how to configure best comcast how to configure modem router — September 18, 2014 @ 3:13 am

  23. You really make it seem so easy along with your
    presentation however I in finding this matter to be actually something which I feel I would never
    understand. It seems too complex and very wide for me.
    I’m looking forward to your subsequent post, I
    will attempt to get the cling of it!

    Comment by how to configure best cable best dsl modem for xbox live — September 19, 2014 @ 12:33 am

  24. We’re a group of volunteers and opening a new scheme in our community.
    Your web site provided us with valuable information to work on. You’ve performed a formidable process and our entire group will be thankful to you.

    Comment by how to configure best buy modem for comcast xfinity — September 19, 2014 @ 1:17 am

  25. If some one wishes expert view on the topic of blogging
    afterward i propose him/her to pay a quick visit this webpage, Keep
    up the nice work.

    Comment by how to configure best best comcast how to configure modem — September 19, 2014 @ 4:23 am

  26. My partner and I stumbled over here different page and
    thought I might as well check things out. I like what I see
    so now i’m following you. Look forward to checking out your web page yet again.

    Comment by how to configure best cable best dsl modem for xbox live — September 19, 2014 @ 11:44 am

  27. Very shortly this web site will be famous among all blogging people, due to
    it’s good posts

    Comment by how to configure best best dsl best cable modem for — September 19, 2014 @ 2:02 pm

  28. Thankfulness to my father who stated to me on the topic of this webpage,
    this webpage is really awesome.

    Comment by how to configure best cable best best comcast modem for — September 19, 2014 @ 4:56 pm

  29. This web site definitely has all the information and facts I wanted concerning this subject and didn’t know who to ask.

    Comment by how how how how to configure modem billion — September 20, 2014 @ 4:42 am

  30. Useful information. Fortunate me I found your website by accident,
    and I’m stunned why this coincidence did not took place
    earlier! I bookmarked it.

    Comment by how to configure streamyx billion modem — September 20, 2014 @ 10:20 am

  31. After checking out a number of the articles on your website, I really appreciate your way of writing a
    blog. I added it to my bookmark website list and will be checking back in the near future.
    Please visit my website too and let me know your opinion.

    Comment by how to configure adsl best best modem for bsnl broadband — September 20, 2014 @ 11:06 am

  32. I was wondering if you ever thought of changing the layout of your website?
    Its very well written; I love what youve got to say. But maybe you could
    a little more in the way of content so people could connect with
    it better. Youve got an awful lot of text for only having one or two images.
    Maybe you could space it out better?

    Comment by Hermina H. Gasner — September 21, 2014 @ 6:11 am

  33. It’s very straightforward to find out any matter on net as compared to books, as I found
    this post at this site.

    Comment by how to configure best best dsl best modem for xbox live — September 21, 2014 @ 1:51 pm

  34. Heya i’m for the first time here. I found this board and I find It truly useful & it helped me out much.
    I hope to give something back and aid others like you helped me.

    Comment by how to configure best comcast do you do u need a modem — September 21, 2014 @ 2:47 pm

  35. I know this web page provides quality depending content and additional data, is there any other site
    which offers these kinds of information in quality?

    Comment by how to configure best cable how to configure modem router — September 21, 2014 @ 3:25 pm

  36. What’s Happening i am new to this, I stumbled upon this I’ve found It absolutely helpful and it has aided
    me out loads. I hope to contribute & help different customers like its aided me.
    Great job.

    Comment by how to configure best comcast dsl dsl modem for xbox live — September 22, 2014 @ 6:37 pm

  37. I usually do not write many comments, but i did some searching and wound up here
    Checking if executescalar returns a result in VB.Net | Thomas’
    Developer Blog. And I actually do have a few questions for you if you don’t mind.
    Could it be only me or does it look like some of the remarks
    come across like written by brain dead visitors? :-P And, if you are posting
    on additional sites, I’d like to keep up with anything new you have to post.

    Would you make a list of every one of your public sites like your Facebook page, twitter feed,
    or linkedin profile?

    Comment by how to configure best arris tg862g \/ct xfinity arris tg862 — September 23, 2014 @ 1:19 am

  38. Hi, I think your blog might be having browser
    compatibility issues. When I look at your blog site in Chrome, it looks fine but when opening in Internet
    Explorer, it has some overlapping. I just wanted to
    give you a quick heads up! Other then that, awesome
    blog!

    Comment by how to configure best cable best cable modem for — September 23, 2014 @ 12:15 pm

  39. If you are going for best contents like myself,
    simply go to see this website everyday since it provides quality contents, thanks

    Comment by Margeret B. Ruh — September 23, 2014 @ 4:53 pm

  40. It’s very straightforward to find out any topic on web as compared to textbooks,
    as I found this post at this web page.

    Comment by Staci I. Wilmot — September 24, 2014 @ 10:11 pm

  41. Good article. I am going through some of these issues as well..

    Comment by how to configure best cable how to connect xbox 360 — September 24, 2014 @ 11:48 pm

  42. You really make it seem so easy with your presentation but I find this matter to be really something that I think I would never understand.
    It seems too complicated and extremely broad for me.
    I am looking forward for your next post, I will try to get the hang of
    it!

    Comment by how to configure best cable dsl the best modem for xbox — September 25, 2014 @ 12:45 am

  43. Thanks for any other excellent post. The place else may just
    anyone get that kind of info in such a perfect method of writing?
    I have a presentation next week, and I’m at the search for such info.

    Comment by Lita B. Corujo — September 25, 2014 @ 3:40 pm

  44. This piece of writing provides clear idea in favor of the
    new people of blogging, that really how to do running a blog.

    Comment by how to configure best cable do you i need a modem for — September 26, 2014 @ 6:01 am

  45. Aw, this was a really nice post. Taking a few minutes and actual effort to produce a
    good article… but what can I say… I put things off a whole lot and never manage to get
    nearly anything done.

    Comment by how to configure best best best modem for bsnl broadband — September 26, 2014 @ 6:17 am

  46. I am really thankful to the holder of this site who has shared this fantastic article at at this time.

    Comment by how to configure best buy best wireless modem for comcast — September 27, 2014 @ 4:29 pm

  47. Hi, after reading this awesome piece of
    writing i am too happy to share my experience here with
    friends.

    Comment by how to configure best best cable do you need a modem for — September 27, 2014 @ 4:32 pm

  48. I don’t even know how I ended up here, but I thought this
    post was great. I don’t know who you are but definitely you’re going to a famous blogger if you aren’t already ;) Cheers!

    Comment by how to configure best best cable best dsl modem for xbox — September 28, 2014 @ 3:30 am

  49. Yes! Finally something about how to configure best buying a motorola cable modem for.

    Comment by how to configure best comcast best dsl modem for xbox live — September 28, 2014 @ 2:16 pm

  50. Hi there, I want to subscribe for this blog to take most recent updates, therefore
    where can i do it please help.

    Comment by how to configure best comcast best best att dsl modem for — September 28, 2014 @ 7:10 pm

  51. I was wondering if you ever thought of changing the layout of your site?
    Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could
    connect with it better. Youve got an awful lot of text for only having 1 or
    two pictures. Maybe you could space it out
    better?

    Comment by how to configure best cable dsl do you need a modem for — September 29, 2014 @ 12:17 am

  52. It’s remarkable to visit this website and reading the views of all colleagues
    concerning this article, while I am also zealous of getting know-how.

    Comment by how to configure best buy best wireless cable modem — September 30, 2014 @ 6:04 pm

  53. You ought to be a part of a contest for one of the most useful sites on the web.
    I’m going to recommend this blog!

    Comment by how to configure best cable dsl how to configure modem — September 30, 2014 @ 6:23 pm

  54. Excellent site you have here but I was wanting to know if you knew of any
    user discussion forums that cover the same topics discussed in this article?
    I’d really like to be a part of online community where I can get responses from other knowledgeable
    people that share the same interest. If you have
    any recommendations, please let me know. Thanks a lot!

    Comment by how to configure best best motorola cable modem for — September 30, 2014 @ 6:58 pm

  55. Hello very cool site!! Man .. Excellent .. Wonderful ..
    I will bookmark your web site and take the feeds also?
    I am glad to find a lot of helpful information right here within the submit,
    we’d like develop more techniques on this regard, thanks for sharing.

    . . . . .

    Comment by how to configure best buying a buying a cable modem for — September 30, 2014 @ 8:24 pm

  56. Thanks on your marvelous posting! I actually enjoyed reading it, you can be
    a great author.I will make sure to bookmark your blog and will
    often come back very soon. I want to encourage that you continue your great writing,
    have a nice day!

    Comment by how to configure best cable the whats the best modem — September 30, 2014 @ 10:20 pm

  57. Now I am going to do my breakfast, later than having my breakfast coming over again to read more news.

    Comment by Idell I. Spilis — October 1, 2014 @ 3:52 am

  58. Pretty section of content. I just stumbled upon your site and in accession capital to assert that I acquire actually enjoyed account your blog posts.

    Anyway I’ll be subscribing to your feeds and even I
    achievement you access consistently rapidly.

    Comment by how to configure best best best docsis 3 cable modem — October 1, 2014 @ 5:58 am

  59. This website truly has all the information and facts I needed about this subject and didn’t know who to ask.

    Comment by how to configure best comcast best cable dsl modem for — October 1, 2014 @ 7:32 am

  60. Love your post. Have you at any time imagined about producing much more about this subject?
    cartiet love bracelet replica http://www.rosegoldlovejewelry.com/

    Comment by vuqdqijwzg@aol.com — July 25, 2015 @ 4:47 pm

  61. You are so cool! I don’t suppose I have read anything like this before.
    So wonderful to find someone with original thoughts on this subject matter.
    Really.. thank you for starting this up. This web site is one thing that
    is required on the internet, someone with some originality!

    Comment by aphorismen das leben — May 19, 2016 @ 7:36 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: