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. Database & SysAdmin
  3. Database
  4. Insertion in table

Insertion in table

Scheduled Pinned Locked Moved Database
databasecsharpcsssharepointsql-server
12 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
    Syed Mujtaba Hassan
    wrote on last edited by
    #1

    I am using SQL Server EXPRESS Edition for my C# client. I have written an SP InsertData for inserting data into a table. Another SP GETDATA fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I call InsertData SP and then in the same event handler I call GETDATA SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.

    Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

    N S A P 4 Replies Last reply
    0
    • S Syed Mujtaba Hassan

      I am using SQL Server EXPRESS Edition for my C# client. I have written an SP InsertData for inserting data into a table. Another SP GETDATA fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I call InsertData SP and then in the same event handler I call GETDATA SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.

      Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Have you tried to run InserData via query analyzer ? Put break points and step into the code.

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      S 1 Reply Last reply
      0
      • N N a v a n e e t h

        Have you tried to run InserData via query analyzer ? Put break points and step into the code.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        S Offline
        S Offline
        Syed Mujtaba Hassan
        wrote on last edited by
        #3

        Yes I have tried the procedure in query analyser and it inserts data successfully. I have added 4 records in tabale using this SP but and everytime I start application, it starts from ID = 5 (ID is IDENTITY column).

        Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

        1 Reply Last reply
        0
        • S Syed Mujtaba Hassan

          I am using SQL Server EXPRESS Edition for my C# client. I have written an SP InsertData for inserting data into a table. Another SP GETDATA fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I call InsertData SP and then in the same event handler I call GETDATA SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.

          Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

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

          Just a lil doubt, are you explicitly opening transactions? If yes, you'll have to commit your transactions by using the COMMIT keyword everytime you insert a row. By default AUTO COMMIT is ON in SQL Server. Check your connection properties to see if its turned off somewhere.

          SG Cause is effect concealed. Effect is cause revealed.

          modified on Monday, March 24, 2008 5:39 AM

          S 1 Reply Last reply
          0
          • S SimulationofSai

            Just a lil doubt, are you explicitly opening transactions? If yes, you'll have to commit your transactions by using the COMMIT keyword everytime you insert a row. By default AUTO COMMIT is ON in SQL Server. Check your connection properties to see if its turned off somewhere.

            SG Cause is effect concealed. Effect is cause revealed.

            modified on Monday, March 24, 2008 5:39 AM

            S Offline
            S Offline
            Syed Mujtaba Hassan
            wrote on last edited by
            #5

            No I am not using this statment and I have also checked SqlCommand object's propertys using it like this com.Transaction.Commit(); function but it is not working. :( I think it is the problem of SQLEXPRESS that may does not allow inserting or updating by default. If anyone give any idea about it, I shall be thankful.

            Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

            1 Reply Last reply
            0
            • S Syed Mujtaba Hassan

              I am using SQL Server EXPRESS Edition for my C# client. I have written an SP InsertData for inserting data into a table. Another SP GETDATA fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I call InsertData SP and then in the same event handler I call GETDATA SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.

              Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

              A Offline
              A Offline
              Andy_L_J
              wrote on last edited by
              #6

              Check your connection string/properties. Are you connecting to SQL Express as 'User Instance = True' ?

              I don't speak Idiot - please talk slowly and clearly

              S 1 Reply Last reply
              0
              • A Andy_L_J

                Check your connection string/properties. Are you connecting to SQL Express as 'User Instance = True' ?

                I don't speak Idiot - please talk slowly and clearly

                S Offline
                S Offline
                Syed Mujtaba Hassan
                wrote on last edited by
                #7

                Yes this property is set to true as 'User Instance = True'. I think it might be some limitation of SQL EXpress but uptil now I haven't come to know about any such limitation. Same problem also posted here by someone. http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2555908&SiteID=17[^]

                Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

                A 1 Reply Last reply
                0
                • S Syed Mujtaba Hassan

                  Yes this property is set to true as 'User Instance = True'. I think it might be some limitation of SQL EXpress but uptil now I haven't come to know about any such limitation. Same problem also posted here by someone. http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2555908&SiteID=17[^]

                  Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

                  A Offline
                  A Offline
                  Andy_L_J
                  wrote on last edited by
                  #8

                  Make sure your connections string says something like: Database='Path&FileName';...;User Instance = False

                  I don't speak Idiot - please talk slowly and clearly

                  S 1 Reply Last reply
                  0
                  • A Andy_L_J

                    Make sure your connections string says something like: Database='Path&FileName';...;User Instance = False

                    I don't speak Idiot - please talk slowly and clearly

                    S Offline
                    S Offline
                    Syed Mujtaba Hassan
                    wrote on last edited by
                    #9

                    Well everything is fine with connection string and application works fine enough as far as it is in RAM but acutal changes are not commited.

                    Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

                    1 Reply Last reply
                    0
                    • S Syed Mujtaba Hassan

                      I am using SQL Server EXPRESS Edition for my C# client. I have written an SP InsertData for inserting data into a table. Another SP GETDATA fetch all the data from the table. Now the problem is with my C# client application. On the main Form I have placed a grid which is filled by calling GETDATA stored procedure. There are text fields and an ADD button on the main form. When I click add button I call InsertData SP and then in the same event handler I call GETDATA SP again to refresh my grid. It works well and show data in grid but later when I check the database no entry is inserted in the database. Again I run the application and database is in the previous state (i.e. no data is found that was inserted in the previous run). In other words data is shown to be inserted but is not actually inserted in the database. What could be the problem? For refernce I have checked msdn where someone has posted the same problem here. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2888935&SiteID=1[^] but no satisfactory answer found up till now.

                      Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #10

                      Oh dear. This old chestnut again. I assume that you are running SQL Server Express as part of your application and that you have a local database. Here's a hint - when the application runs, the database is copied into the bin directory (everytime it's run from the Visual Studio menu). This means that the work you've inserted effectively disappears because it has been replaced by a new copy of the database. In order to see the data, you need to look in the Debug (or Release depending on your build mechanism) directory where you will be able to see the database. You can open it up and take a look at it in there.

                      Deja View - the feeling that you've seen this post before.

                      My blog | My articles

                      S 1 Reply Last reply
                      0
                      • P Pete OHanlon

                        Oh dear. This old chestnut again. I assume that you are running SQL Server Express as part of your application and that you have a local database. Here's a hint - when the application runs, the database is copied into the bin directory (everytime it's run from the Visual Studio menu). This means that the work you've inserted effectively disappears because it has been replaced by a new copy of the database. In order to see the data, you need to look in the Debug (or Release depending on your build mechanism) directory where you will be able to see the database. You can open it up and take a look at it in there.

                        Deja View - the feeling that you've seen this post before.

                        My blog | My articles

                        S Offline
                        S Offline
                        Syed Mujtaba Hassan
                        wrote on last edited by
                        #11

                        Thank u very mcuh Henlon. That was AWESOME. [:)] That really works. When I opened the database from bin folder it contained all the data that was inserted earlier. I don't know how should I say thank u to u. Thank u so much. [;)]

                        Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

                        P 1 Reply Last reply
                        0
                        • S Syed Mujtaba Hassan

                          Thank u very mcuh Henlon. That was AWESOME. [:)] That really works. When I opened the database from bin folder it contained all the data that was inserted earlier. I don't know how should I say thank u to u. Thank u so much. [;)]

                          Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."

                          P Offline
                          P Offline
                          Pete OHanlon
                          wrote on last edited by
                          #12

                          No problem. I'm glad I could help.

                          Deja View - the feeling that you've seen this post before.

                          My blog | My articles

                          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