Problem In bind DATAGRIED
-
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
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("لطفا شابک کتاب
-
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("لطفا شابک کتاب
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
-
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 WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:
dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));
-
I WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:
dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));
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 WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:
dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));
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.
-
I WANT TO DATA SHOW IN DATAGRID BUT IN DATASOURCE EOOR error is in line:
dataGridViewX2.DataBindings.Add(new Binding("DataSource", dsDataBook, "tblbooks"));
-
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"...
error text is:Argument Eception Was Unhandled Cannot bind to the property or column tblmembers on the DataSource. Parameter name: dataMember
-
error text is:Argument Eception Was Unhandled Cannot bind to the property or column tblmembers on the DataSource. Parameter name: dataMember
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
-
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
yes i can save record in database but i can not view in datagrid
-
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("لطفا شابک کتاب
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 :)