Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Checking for data

Checking for data

Scheduled Pinned Locked Moved C#
databaseperformancecsharpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    ziwez0
    wrote on last edited by
    #1

    Hi Guys and Gals, I have my c# win form app connected up to a sql compact db. I have a form which contains fields to enter company data, ie an address. Now at the moment when I open that form, I do a read to see if a record exists... xDataSourceAccess = AppSet.DataSourceAccess; conn = new SqlCeConnection(Properties.Settings.Default.CS_Account + xDataSourceAccess); string strRecordExisit = "SELECT OID from tbl_CompanyDetails"; conn.Open(); cmd = new SqlCeCommand(strRecordExisit,conn); Reader = cmd.ExecuteReader(); if (Reader.Read()) xRecordFound = true; Reader.Close(); etc.... Is this the the best way to check to see if a record exists? (ie best performance and memory usage) thanks

    D 1 Reply Last reply
    0
    • Z ziwez0

      Hi Guys and Gals, I have my c# win form app connected up to a sql compact db. I have a form which contains fields to enter company data, ie an address. Now at the moment when I open that form, I do a read to see if a record exists... xDataSourceAccess = AppSet.DataSourceAccess; conn = new SqlCeConnection(Properties.Settings.Default.CS_Account + xDataSourceAccess); string strRecordExisit = "SELECT OID from tbl_CompanyDetails"; conn.Open(); cmd = new SqlCeCommand(strRecordExisit,conn); Reader = cmd.ExecuteReader(); if (Reader.Read()) xRecordFound = true; Reader.Close(); etc.... Is this the the best way to check to see if a record exists? (ie best performance and memory usage) thanks

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Yep, pretty much. Any other methods you use are going to boil down to the same technique. Though, I'd probably have a stored procedure that checks for the existance and passes back a True/False, or a record count if there is more than one record your checking for in the same table.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      D 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Yep, pretty much. Any other methods you use are going to boil down to the same technique. Though, I'd probably have a stored procedure that checks for the existance and passes back a True/False, or a record count if there is more than one record your checking for in the same table.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        IIRC you can't use stored procedures in SQL Compact.

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

        D 1 Reply Last reply
        0
        • D DaveyM69

          IIRC you can't use stored procedures in SQL Compact.

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Hmmm...didn't know that. I've never used it before, having gone only as low as Express. Just goes to show you what "assume" really stands for! :-D

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups