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. Problem in SqlExpress

Problem in SqlExpress

Scheduled Pinned Locked Moved C#
databasesecurityhelpquestionannouncement
13 Posts 5 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.
  • S Offline
    S Offline
    SajjadZare
    wrote on last edited by
    #1

    I Add a database to my program in this way : Right Click on my program in Solution ->Add->Add Existing Item -> Select DB connectionString : Data Source=.\\SQLEXPRESS;AttachDbFilename="+Directory.GetCurrentDirectory()+"\\TMC.mdf;Integrated Security=True;User Instance=True when I select everything is ok problem : when I insert,delete,update nothing change in DataBase why?

    A realJSOPR D C 4 Replies Last reply
    0
    • S SajjadZare

      I Add a database to my program in this way : Right Click on my program in Solution ->Add->Add Existing Item -> Select DB connectionString : Data Source=.\\SQLEXPRESS;AttachDbFilename="+Directory.GetCurrentDirectory()+"\\TMC.mdf;Integrated Security=True;User Instance=True when I select everything is ok problem : when I insert,delete,update nothing change in DataBase why?

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      SajjadZare wrote:

      when I insert,delete,update nothing change in DataBase

      Are you sure? Ifyou are looking at the data in your application you need to refresh your datasource to see changes. Look directly in the database to see if it has been updated.

      Bob Ashfield Consultants Ltd Proud to be a Code Project MVP

      S 1 Reply Last reply
      0
      • S SajjadZare

        I Add a database to my program in this way : Right Click on my program in Solution ->Add->Add Existing Item -> Select DB connectionString : Data Source=.\\SQLEXPRESS;AttachDbFilename="+Directory.GetCurrentDirectory()+"\\TMC.mdf;Integrated Security=True;User Instance=True when I select everything is ok problem : when I insert,delete,update nothing change in DataBase why?

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        check the exception that's being generated.

        .45 ACP - because shooting twice is just silly
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

        1 Reply Last reply
        0
        • A Ashfield

          SajjadZare wrote:

          when I insert,delete,update nothing change in DataBase

          Are you sure? Ifyou are looking at the data in your application you need to refresh your datasource to see changes. Look directly in the database to see if it has been updated.

          Bob Ashfield Consultants Ltd Proud to be a Code Project MVP

          S Offline
          S Offline
          SajjadZare
          wrote on last edited by
          #4

          It's update at first but when I close the program and run it the record that I inserted dosen't exist

          realJSOPR 1 Reply Last reply
          0
          • S SajjadZare

            It's update at first but when I close the program and run it the record that I inserted dosen't exist

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            Did you use commit in your sql?

            .45 ACP - because shooting twice is just silly
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

            S 1 Reply Last reply
            0
            • S SajjadZare

              I Add a database to my program in this way : Right Click on my program in Solution ->Add->Add Existing Item -> Select DB connectionString : Data Source=.\\SQLEXPRESS;AttachDbFilename="+Directory.GetCurrentDirectory()+"\\TMC.mdf;Integrated Security=True;User Instance=True when I select everything is ok problem : when I insert,delete,update nothing change in DataBase why?

              D Offline
              D Offline
              Dimitri Witkowski
              wrote on last edited by
              #6

              How do you insert, delete and update?

              See my article about Windows 7 Taskbar timer here on CodeProject

              S 1 Reply Last reply
              0
              • S SajjadZare

                I Add a database to my program in this way : Right Click on my program in Solution ->Add->Add Existing Item -> Select DB connectionString : Data Source=.\\SQLEXPRESS;AttachDbFilename="+Directory.GetCurrentDirectory()+"\\TMC.mdf;Integrated Security=True;User Instance=True when I select everything is ok problem : when I insert,delete,update nothing change in DataBase why?

                C Offline
                C Offline
                Covean
                wrote on last edited by
                #7

                As you added this database file to your project did you maybe select "always copy" on the "copy to output directory" property (I don't know the exact phrase in the english studio for this)? Because this overrides the "modified" database file with the old one (this will be done every time you build your project). If so, try to use the setting "only if newer".

                Greetings Covean

                S 1 Reply Last reply
                0
                • realJSOPR realJSOP

                  Did you use commit in your sql?

                  .45 ACP - because shooting twice is just silly
                  -----
                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                  -----
                  "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                  S Offline
                  S Offline
                  SajjadZare
                  wrote on last edited by
                  #8

                  What's Commit

                  realJSOPR 1 Reply Last reply
                  0
                  • D Dimitri Witkowski

                    How do you insert, delete and update?

                    See my article about Windows 7 Taskbar timer here on CodeProject

                    S Offline
                    S Offline
                    SajjadZare
                    wrote on last edited by
                    #9

                    with procedure and I examined these procedure with other database and these procedure work correctly

                    1 Reply Last reply
                    0
                    • C Covean

                      As you added this database file to your project did you maybe select "always copy" on the "copy to output directory" property (I don't know the exact phrase in the english studio for this)? Because this overrides the "modified" database file with the old one (this will be done every time you build your project). If so, try to use the setting "only if newer".

                      Greetings Covean

                      S Offline
                      S Offline
                      SajjadZare
                      wrote on last edited by
                      #10

                      How do you add database to program like this ? can you tell me step by step ?

                      C 1 Reply Last reply
                      0
                      • S SajjadZare

                        How do you add database to program like this ? can you tell me step by step ?

                        C Offline
                        C Offline
                        Covean
                        wrote on last edited by
                        #11

                        I would do it like to op wrote. He added the db file <currentdir>\tmc.mdf. Right Click on my program in Solution ->Add->Add Existing Item -> Select DB connectionString : Data Source=.\\SQLEXPRESS;AttachDbFilename="+Directory.GetCurrentDirectory()+"\\TMC.mdf;Integrated Security=True;User Instance=True;

                        Greetings Covean

                        S 1 Reply Last reply
                        0
                        • S SajjadZare

                          What's Commit

                          realJSOPR Offline
                          realJSOPR Offline
                          realJSOP
                          wrote on last edited by
                          #12

                          It's a sql command that makes db changes (to tables) permanent. Learn how to use google.

                          .45 ACP - because shooting twice is just silly
                          -----
                          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                          -----
                          "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                          1 Reply Last reply
                          0
                          • C Covean

                            I would do it like to op wrote. He added the db file <currentdir>\tmc.mdf. Right Click on my program in Solution ->Add->Add Existing Item -> Select DB connectionString : Data Source=.\\SQLEXPRESS;AttachDbFilename="+Directory.GetCurrentDirectory()+"\\TMC.mdf;Integrated Security=True;User Instance=True;

                            Greetings Covean

                            S Offline
                            S Offline
                            SajjadZare
                            wrote on last edited by
                            #13

                            so in this way I couldn't find this : <>

                            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