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. Databinding small mistakes

Databinding small mistakes

Scheduled Pinned Locked Moved C#
graphicshelp
8 Posts 6 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.
  • T Offline
    T Offline
    Trustapple
    wrote on last edited by
    #1

    Hello, Am trying to bind data.This is my code.Is there any problem with my code since it does not seem to work. Take your time. Thanking You using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace TestDb { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnInsert_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "Insert into MyTable(Name) values ('" + txtName.Text + "')"; cmdObj.Connection = conObj; cmdObj.ExecuteNonQuery(); txtName.Clear(); } private void btnBind_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "select Name from MyTable"; DataSet ds = new DataSet(); cmdObj.Connection = conObj; OleDbDataAdapter adapObj = new OleDbDataAdapter(); adapObj.SelectCommand = cmdObj; adapObj.Fill(ds); } } }

    J P A 3 Replies Last reply
    0
    • T Trustapple

      Hello, Am trying to bind data.This is my code.Is there any problem with my code since it does not seem to work. Take your time. Thanking You using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace TestDb { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnInsert_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "Insert into MyTable(Name) values ('" + txtName.Text + "')"; cmdObj.Connection = conObj; cmdObj.ExecuteNonQuery(); txtName.Clear(); } private void btnBind_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "select Name from MyTable"; DataSet ds = new DataSet(); cmdObj.Connection = conObj; OleDbDataAdapter adapObj = new OleDbDataAdapter(); adapObj.SelectCommand = cmdObj; adapObj.Fill(ds); } } }

      J Offline
      J Offline
      Justin Perez
      wrote on last edited by
      #2

      Trustapple wrote:

      Hello, Am trying to bind data.This is my code.Is there any problem with my code since it does not seem to work. Take your time. Thanking You

      I didn't look at the code you provided, because you weren't specific. When you say "it doesn't work," you need to be more specific. How does it not work? Does it get errors on build, a run-time exception, or does it just sit there and do nothing? Have you tried setting breakpoints to see what your code is doing?

      I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer

      1 Reply Last reply
      0
      • T Trustapple

        Hello, Am trying to bind data.This is my code.Is there any problem with my code since it does not seem to work. Take your time. Thanking You using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace TestDb { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnInsert_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "Insert into MyTable(Name) values ('" + txtName.Text + "')"; cmdObj.Connection = conObj; cmdObj.ExecuteNonQuery(); txtName.Clear(); } private void btnBind_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "select Name from MyTable"; DataSet ds = new DataSet(); cmdObj.Connection = conObj; OleDbDataAdapter adapObj = new OleDbDataAdapter(); adapObj.SelectCommand = cmdObj; adapObj.Fill(ds); } } }

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        In future posts, please use the <code></code> tags to make your code easier to read :-D

        "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

        L 1 Reply Last reply
        0
        • P Paul Conrad

          In future posts, please use the <code></code> tags to make your code easier to read :-D

          "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Paul Conrad wrote:

          please use the <code></code> tags

          Absolutely not. Don't use CODE tags for multi-line stuff, they are for single-line things only. Multi-line code should be in PRE tags which preserves formatting. With two caveats: - empty lines disappear, so add a space tot them - less-than signs followed by a letter will be eaten by the HTML deamon, therefore replace < by < :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


          P 1 Reply Last reply
          0
          • L Luc Pattyn

            Paul Conrad wrote:

            please use the <code></code> tags

            Absolutely not. Don't use CODE tags for multi-line stuff, they are for single-line things only. Multi-line code should be in PRE tags which preserves formatting. With two caveats: - empty lines disappear, so add a space tot them - less-than signs followed by a letter will be eaten by the HTML deamon, therefore replace < by < :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


            P Offline
            P Offline
            Paul Conrad
            wrote on last edited by
            #5

            That's right, my bad. I remember we did a big investigation on this last summer :-D I thought it was pre and code together.

            "What's your question? All I see is some deranged, half-assed looking run-on sentence. Where are you having problems?" - Justin Perez

            D 1 Reply Last reply
            0
            • P Paul Conrad

              That's right, my bad. I remember we did a big investigation on this last summer :-D I thought it was pre and code together.

              "What's your question? All I see is some deranged, half-assed looking run-on sentence. Where are you having problems?" - Justin Perez

              D Offline
              D Offline
              DeepToot
              wrote on last edited by
              #6

              someone should sticky this..I keep forgetting.

              Steve Welborn Software Engineer Inrange Consulting

              P 1 Reply Last reply
              0
              • D DeepToot

                someone should sticky this..I keep forgetting.

                Steve Welborn Software Engineer Inrange Consulting

                P Offline
                P Offline
                Paul Conrad
                wrote on last edited by
                #7

                Look at Luc's article he did on the topic.

                "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

                1 Reply Last reply
                0
                • T Trustapple

                  Hello, Am trying to bind data.This is my code.Is there any problem with my code since it does not seem to work. Take your time. Thanking You using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace TestDb { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnInsert_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "Insert into MyTable(Name) values ('" + txtName.Text + "')"; cmdObj.Connection = conObj; cmdObj.ExecuteNonQuery(); txtName.Clear(); } private void btnBind_Click(object sender, EventArgs e) { OleDbConnection conObj = new OleDbConnection(); conObj.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\j\My Documents\MyDb.mdb"; conObj.Open(); OleDbCommand cmdObj = new OleDbCommand(); cmdObj.CommandText = "select Name from MyTable"; DataSet ds = new DataSet(); cmdObj.Connection = conObj; OleDbDataAdapter adapObj = new OleDbDataAdapter(); adapObj.SelectCommand = cmdObj; adapObj.Fill(ds); } } }

                  A Offline
                  A Offline
                  Adeel Chaudhry
                  wrote on last edited by
                  #8

                  Trustapple wrote:

                  using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb;

                  Can you paste the code of libraries you used as well?

                  Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

                  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