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 bind DATAGRIED

Problem In bind DATAGRIED

Scheduled Pinned Locked Moved C#
databasequestionsql-serverwpfwcf
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
    shahramkeyboard
    wrote on last edited by
    #1

    MY CONECTION STRIN IS:

    private const string CnnStr = "Data Source=(local);Initial Catalog=Library;Integrated Security=SSPI;";

    MY datagrid bind is:

    dataGridViewX1.DataBindings.Add(new Binding("Data Source", dsDataMember, "tblmembers"));

    My Database is Sql server 2008 What is the Problem?

    OriginalGriffO 1 Reply Last reply
    0
    • S shahramkeyboard

      MY CONECTION STRIN IS:

      private const string CnnStr = "Data Source=(local);Initial Catalog=Library;Integrated Security=SSPI;";

      MY datagrid bind is:

      dataGridViewX1.DataBindings.Add(new Binding("Data Source", dsDataMember, "tblmembers"));

      My Database is Sql server 2008 What is the Problem?

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

      shahramkeyboard wrote:

      What is the Problem?

      That is a very good question! Unfortunately, you forgot to tell us that bit. What is happening? What is not happening? What do you expect to happen? Does it compile? Does it throw an exception? Go on, you know you want to tell us!

      You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

      "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

      S 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        shahramkeyboard wrote:

        What is the Problem?

        That is a very good question! Unfortunately, you forgot to tell us that bit. What is happening? What is not happening? What do you expect to happen? Does it compile? Does it throw an exception? Go on, you know you want to tell us!

        You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

        S Offline
        S Offline
        shahramkeyboard
        wrote on last edited by
        #3

        My Book Business logic Layer is:

        using System;
        using System.Data;
        using System.Text;
        using System.Data.SqlClient;

        namespace Library_Project
        {
        public class bookBL
        {
        //Book properties
        private String bookcode;
        private String bookname;
        private String shabok;
        private String nasher;
        private String motarjem;
        private String mozo;

                private bookDA bookData;
        
           // BUSINESS LOGIC BOOK 
           public bookBL()            
           {
             
               //Data access layer!
         
               bookData = new bookDA();
        
           }
        
           /// <SUMMARY>
           /// Property BookCode (String)
           /// </SUMMARY>
           public String Bookcode
           {
               get
               {
                   return this.bookcode;
               }
               set
               {
                   this.bookcode = value;
        
        
               }
           }
        
                /// <SUMMARY>
                /// Property BooktName (String)
                /// </SUMMARY>
                public String Bookname 
                {
          
                      get
                      {
                          return this.bookname;
                      }
                      set
                      {
                            try
                            {
                                this.bookname = value;
        
                                if (this.bookname == "")
                                  {
                                        throw new Exception(
                                          "لطفا نام کتاب را وارد نمایید");
                                  }
                            }
                            catch(Exception e)
                            {
                                  throw new Exception(e.Message.ToString());
                            }
                      }
                }
        
                /// <SUMMARY>
                /// Property ISBN (String)
                /// </SUMMARY>
                public String Shabok
                {
                      get
                      {
                            return this.shabok;
                      }
                      set
                      {
                            //could be more checkings here eg revmove ' chars
                            //change to proper case
                            //blah blah
                            this.shabok = value;
                            if (this.shabok == "")
                            {
                                  throw new Exception("لطفا شابک کتاب
        
        OriginalGriffO 0 2 Replies Last reply
        0
        • S shahramkeyboard

          My Book Business logic Layer is:

          using System;
          using System.Data;
          using System.Text;
          using System.Data.SqlClient;

          namespace Library_Project
          {
          public class bookBL
          {
          //Book properties
          private String bookcode;
          private String bookname;
          private String shabok;
          private String nasher;
          private String motarjem;
          private String mozo;

                  private bookDA bookData;
          
             // BUSINESS LOGIC BOOK 
             public bookBL()            
             {
               
                 //Data access layer!
           
                 bookData = new bookDA();
          
             }
          
             /// <SUMMARY>
             /// Property BookCode (String)
             /// </SUMMARY>
             public String Bookcode
             {
                 get
                 {
                     return this.bookcode;
                 }
                 set
                 {
                     this.bookcode = value;
          
          
                 }
             }
          
                  /// <SUMMARY>
                  /// Property BooktName (String)
                  /// </SUMMARY>
                  public String Bookname 
                  {
            
                        get
                        {
                            return this.bookname;
                        }
                        set
                        {
                              try
                              {
                                  this.bookname = value;
          
                                  if (this.bookname == "")
                                    {
                                          throw new Exception(
                                            "لطفا نام کتاب را وارد نمایید");
                                    }
                              }
                              catch(Exception e)
                              {
                                    throw new Exception(e.Message.ToString());
                              }
                        }
                  }
          
                  /// <SUMMARY>
                  /// Property ISBN (String)
                  /// </SUMMARY>
                  public String Shabok
                  {
                        get
                        {
                              return this.shabok;
                        }
                        set
                        {
                              //could be more checkings here eg revmove ' chars
                              //change to proper case
                              //blah blah
                              this.shabok = value;
                              if (this.shabok == "")
                              {
                                    throw new Exception("لطفا شابک کتاب
          
          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          That's a lot of code to wade through! Without your database, no one can run it - not that they would, probably. Don't try to post your database here - just answer the questions: 1) What is happening when you run the program? 2) What did you expect to happen?

          You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

          "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

          S 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            That's a lot of code to wade through! Without your database, no one can run it - not that they would, probably. Don't try to post your database here - just answer the questions: 1) What is happening when you run the program? 2) What did you expect to happen?

            You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

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

            I WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:

            dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));

            OriginalGriffO L L 3 Replies Last reply
            0
            • S shahramkeyboard

              I WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:

              dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));

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

              shahramkeyboard wrote:

              WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR

              No need to shout!

              shahramkeyboard wrote:

              error is in line: dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));

              And what is the error? I assume it is an exception - what is the exception saying?

              You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

              "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

              1 Reply Last reply
              0
              • S shahramkeyboard

                I WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:

                dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));

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

                you have shown lots of useless code and wasted three hours already. You should have given detailed symptoms in your very first message. We still don't know what error occurred. If it is an exception, show all of the Exception.ToString() output and point at the right line of code. :(

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


                1 Reply Last reply
                0
                • S shahramkeyboard

                  I WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:

                  dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  you must explain your error. It makes no sense just to say "I HAVE AN ERROR, ERROR, ERROR".... we cannot help you, because you don't even explain the error. It can be from "I FORGOT TO WRITE SEMICOLON" until "MY PC EXPLODED"...

                  S 1 Reply Last reply
                  0
                  • L Lost User

                    you must explain your error. It makes no sense just to say "I HAVE AN ERROR, ERROR, ERROR".... we cannot help you, because you don't even explain the error. It can be from "I FORGOT TO WRITE SEMICOLON" until "MY PC EXPLODED"...

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

                    error text is:Argument Eception Was Unhandled Cannot bind to the property or column tblmembers on the DataSource. Parameter name: dataMember

                    OriginalGriffO 1 Reply Last reply
                    0
                    • S shahramkeyboard

                      error text is:Argument Eception Was Unhandled Cannot bind to the property or column tblmembers on the DataSource. Parameter name: dataMember

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

                      Does this not suggest to you what the problem is? Have a look at your database. Does it have a table called "tblmembers"? Does your connection actually connect to the database at all? Does the database exist?

                      You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

                      "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

                      S 1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        Does this not suggest to you what the problem is? Have a look at your database. Does it have a table called "tblmembers"? Does your connection actually connect to the database at all? Does the database exist?

                        You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy

                        S Offline
                        S Offline
                        shahramkeyboard
                        wrote on last edited by
                        #11

                        yes i can save record in database but i can not view in datagrid

                        1 Reply Last reply
                        0
                        • S shahramkeyboard

                          My Book Business logic Layer is:

                          using System;
                          using System.Data;
                          using System.Text;
                          using System.Data.SqlClient;

                          namespace Library_Project
                          {
                          public class bookBL
                          {
                          //Book properties
                          private String bookcode;
                          private String bookname;
                          private String shabok;
                          private String nasher;
                          private String motarjem;
                          private String mozo;

                                  private bookDA bookData;
                          
                             // BUSINESS LOGIC BOOK 
                             public bookBL()            
                             {
                               
                                 //Data access layer!
                           
                                 bookData = new bookDA();
                          
                             }
                          
                             /// <SUMMARY>
                             /// Property BookCode (String)
                             /// </SUMMARY>
                             public String Bookcode
                             {
                                 get
                                 {
                                     return this.bookcode;
                                 }
                                 set
                                 {
                                     this.bookcode = value;
                          
                          
                                 }
                             }
                          
                                  /// <SUMMARY>
                                  /// Property BooktName (String)
                                  /// </SUMMARY>
                                  public String Bookname 
                                  {
                            
                                        get
                                        {
                                            return this.bookname;
                                        }
                                        set
                                        {
                                              try
                                              {
                                                  this.bookname = value;
                          
                                                  if (this.bookname == "")
                                                    {
                                                          throw new Exception(
                                                            "لطفا نام کتاب را وارد نمایید");
                                                    }
                                              }
                                              catch(Exception e)
                                              {
                                                    throw new Exception(e.Message.ToString());
                                              }
                                        }
                                  }
                          
                                  /// <SUMMARY>
                                  /// Property ISBN (String)
                                  /// </SUMMARY>
                                  public String Shabok
                                  {
                                        get
                                        {
                                              return this.shabok;
                                        }
                                        set
                                        {
                                              //could be more checkings here eg revmove ' chars
                                              //change to proper case
                                              //blah blah
                                              this.shabok = value;
                                              if (this.shabok == "")
                                              {
                                                    throw new Exception("لطفا شابک کتاب
                          
                          0 Offline
                          0 Offline
                          0x3c0
                          wrote on last edited by
                          #12

                          shahramkeyboard wrote:

                          String selectStr = "UPDATE " + thisTable + " set " + book_name + " = '" + book.Bookname + "'" + ", " + book_nasher + " = '" + book.Nasher + "'" + ", " + book_motarjem + " = '" + book.Motarjem + "'" + ", " + book_shabok + " = '" + book.Shabok + "'" + ", " + book_mozo + " = '" + book.Mozo + "'" + " where book_code = '" + book.Bookcode + "'";

                          shahramkeyboard wrote:

                          String selectStr = "select * from " + thisTable + " where code_book = '" + argStr + "'";

                          shahramkeyboard wrote:

                          String selectStr = "select * from " + thisTable + "'";

                          SQL injection. What happens if somebody decides to set argStr to ' DROP TABLE tblbooks;? You might want to use parameterised queries instead of just crossing your fingers and hoping that the user will play nice.

                          OSDev :)

                          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