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. c#

c#

Scheduled Pinned Locked Moved C#
csharpdatabase
8 Posts 7 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.
  • M Offline
    M Offline
    mansingh35
    wrote on last edited by
    #1

    how can we do the database connectivity in c# windows form

    K P A P 4 Replies Last reply
    0
    • M mansingh35

      how can we do the database connectivity in c# windows form

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      Take your pick: ADO.NET Enitiy Framework LINQ to SQL nHibernate.

      Sort of a cross between Lawrence of Arabia and Dilbert.[^]
      -Or-
      A Dead ringer for Kate Winslett[^]

      OriginalGriffO 1 Reply Last reply
      0
      • K Keith Barrow

        Take your pick: ADO.NET Enitiy Framework LINQ to SQL nHibernate.

        Sort of a cross between Lawrence of Arabia and Dilbert.[^]
        -Or-
        A Dead ringer for Kate Winslett[^]

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Keith Barrow wrote:

        Take your pick

        That will only be helpful if he is data mining, surely?

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        K S 2 Replies Last reply
        0
        • OriginalGriffO OriginalGriff

          Keith Barrow wrote:

          Take your pick

          That will only be helpful if he is data mining, surely?

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

          K Offline
          K Offline
          Keith Barrow
          wrote on last edited by
          #4

          I've never been accused of being helpful yet ;-)

          Sort of a cross between Lawrence of Arabia and Dilbert.[^]
          -Or-
          A Dead ringer for Kate Winslett[^]

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Keith Barrow wrote:

            Take your pick

            That will only be helpful if he is data mining, surely?

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

            S Offline
            S Offline
            SledgeHammer01
            wrote on last edited by
            #5

            Lol!

            1 Reply Last reply
            0
            • M mansingh35

              how can we do the database connectivity in c# windows form

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              a) Don't -- never put data access in your UI layer. b) Once you have a Data Access Layer -- access it from your UI layer.

              1 Reply Last reply
              0
              • M mansingh35

                how can we do the database connectivity in c# windows form

                A Offline
                A Offline
                ambarishtv
                wrote on last edited by
                #7

                do it like this.. :)

                using System;
                using System.Collections.Generic;
                using System.Text;
                using System.Data.OleDb;
                namespace Access
                {
                public class Connection
                {
                private string getConnectionString()
                {
                return "connetionString";
                }

                    public static void ExecuteCommand(string command)
                    {
                        OleDbConnection con;
                        OleDbCommand com;
                        try
                        {
                            con = new OleDbConnection(getConnectionString());
                            con.Open();
                            com = new OleDbCommand(command);
                            com.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            //ex shows exception
                        }
                        finally
                        {
                            con.Close();
                        }
                    }
                }
                

                //Call Connection Method public void MyMethord() { Connection.ExecuteCommand("command write here"); }

                -ambarish-

                1 Reply Last reply
                0
                • M mansingh35

                  how can we do the database connectivity in c# windows form

                  P Offline
                  P Offline
                  Prasanta_Prince
                  wrote on last edited by
                  #8

                  public void connection()
                  {
                  con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=practice;Data Source=HOME-78F3176757");
                  con.Open();
                  }

                      public DataSet filldata(string mystring)
                      {
                          connection();
                          adp = new SqlDataAdapter(mystring, con);
                          ds = new DataSet();
                          adp.Fill(ds);
                          return ds;
                      }
                  
                  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