How To Use A Database In Your Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #16
    Originally posted by r035198x
    Checking the returned value of ExecuteNonQuery with 1 to determine success is not correct. The method returns the number of rows updated.
    Thanks r0.
    I fixed it.

    Comment

    • michaeldebruin
      New Member
      • Feb 2011
      • 134

      #17
      Heey Frinavale,

      I've this article about how to connect to a microsoft SQL server. But how about creating a program with C# and connecting that one to a microsoft access Database? Is it the same way or are there some differences? Especially looking to the way to put some data into the database and getting data out of it.

      Kind regards,

      Michael

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #18
        Using an Access Database in your C# application isn't much different than what this article covers.

        Instead of using a SqlConnection, you will use an OleDbConnection. There are a few syntax changes that need to be made to get this to work (ie: your SQL commands and the characters you supply for using parameters etc.) but the concept is the same. Check out this MSDN article about Creating Connections to Access Databases.

        -Frinny

        Comment

        • dhoffman
          New Member
          • Feb 2012
          • 1

          #19
          First time posting here - please excuse my ignorance.

          Could you help output the results from SQL? The result if there is at least one row in the table is sitting in memory. I would like to be able to show those results on an ASP.NET page, in a table or something.

          As I follow along with the tutorial I can look at my database and table within to see the result of successful inserts. I don't have the equivalent for successful selects. It would greatly enhance this example to add a method of seeing that you are successfully inserting and selecting - what better way than sending the results to a dynamically generated table.

          Comment

          • Mudassir
            New Member
            • May 2012
            • 85

            #20
            exactly, you can append the label by looping through the dataset you retrieved from the sql server

            Comment

            • lishniy
              New Member
              • Apr 2013
              • 3

              #21
              How can i browse database name before connect?

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #22
                If you have questions then ask them in the questions area.

                Comment

                • pod
                  Contributor
                  • Sep 2007
                  • 298

                  #23
                  You can use ExecuteScalar when you expect only one value as "Get the Maximum ID"
                  Code:
                  SELECT MAX(ID) as maxid FROM tblData

                  Comment

                  Working...