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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. sql server 3.5

sql server 3.5

Scheduled Pinned Locked Moved C#
databasesql-serversysadminhelp
8 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.
  • L Offline
    L Offline
    lankaudaranga
    wrote on last edited by
    #1

    con.Open(); string select = "select * from main_stock where stockid='" + comboBox1.Text + "'"; SqlCeCommand selcom = new SqlCeCommand(select, con); SqlCeDataReader reader = selcom.ExecuteReader(); reader.Read(); if (reader.HasRows == true) { MessageBox.Show("error"); } con.Close(); this code work access databse but sql server 3.5 compact server notwork

    C 1 Reply Last reply
    0
    • L lankaudaranga

      con.Open(); string select = "select * from main_stock where stockid='" + comboBox1.Text + "'"; SqlCeCommand selcom = new SqlCeCommand(select, con); SqlCeDataReader reader = selcom.ExecuteReader(); reader.Read(); if (reader.HasRows == true) { MessageBox.Show("error"); } con.Close(); this code work access databse but sql server 3.5 compact server notwork

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      lankaudaranga wrote:

      this code work access databse but sql server 3.5 compact server notwork

      What do you mean by "not work". Exactly, how does it not work? What is the error you get?

      Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

      L 1 Reply Last reply
      0
      • C Colin Angus Mackay

        lankaudaranga wrote:

        this code work access databse but sql server 3.5 compact server notwork

        What do you mean by "not work". Exactly, how does it not work? What is the error you get?

        Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

        L Offline
        L Offline
        lankaudaranga
        wrote on last edited by
        #3

        EROOR massege display "hasrow" not supports

        A 1 Reply Last reply
        0
        • L lankaudaranga

          EROOR massege display "hasrow" not supports

          A Offline
          A Offline
          AhsanS
          wrote on last edited by
          #4

          You should had posted the full error description. Any hows do it this way if(dr.Read()) { //your code here }

          Ahsan Ullah Senior Software Engineer

          L 1 Reply Last reply
          0
          • A AhsanS

            You should had posted the full error description. Any hows do it this way if(dr.Read()) { //your code here }

            Ahsan Ullah Senior Software Engineer

            L Offline
            L Offline
            lankaudaranga
            wrote on last edited by
            #5

            YES reader.Read(); if (reader.HasRows == true) { MessageBox.Show("STOCK ID ALREADY EXITS", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); comboBox1.Text = ""; comboBox1.Focus(); } BUT ITS NOT WORK :(

            C 1 Reply Last reply
            0
            • L lankaudaranga

              YES reader.Read(); if (reader.HasRows == true) { MessageBox.Show("STOCK ID ALREADY EXITS", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); comboBox1.Text = ""; comboBox1.Focus(); } BUT ITS NOT WORK :(

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              lankaudaranga wrote:

              reader.Read(); if (reader.HasRows == true)

              NO! That is not what was told to you.

              if(reader.Read()) // Doesn't require HasRows
              {
              // your code here
              }

              Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

              L 1 Reply Last reply
              0
              • C Colin Angus Mackay

                lankaudaranga wrote:

                reader.Read(); if (reader.HasRows == true)

                NO! That is not what was told to you.

                if(reader.Read()) // Doesn't require HasRows
                {
                // your code here
                }

                Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

                L Offline
                L Offline
                lankaudaranga
                wrote on last edited by
                #7

                i want to send data to database but data not duplicate(hasraw==true) if (reader.HasRows == true) { //data already exite no data insert.display massege ..... } else { enter data(insert data } {you undastand this)

                C 1 Reply Last reply
                0
                • L lankaudaranga

                  i want to send data to database but data not duplicate(hasraw==true) if (reader.HasRows == true) { //data already exite no data insert.display massege ..... } else { enter data(insert data } {you undastand this)

                  C Offline
                  C Offline
                  Colin Angus Mackay
                  wrote on last edited by
                  #8

                  Yes, I understand you. However, you don't seem to understand me. To spell it out:

                  if (reader.Read())
                  {
                  // There is data - do something
                  }
                  else
                  {
                  // There is no data - do something else.
                  }

                  So, as you can see, and as I explained earlier, you do not need HasRows.

                  Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

                  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