Home > Net >  Is there a big tell me where there is wrong! The dataset in the data in the database!
Is there a big tell me where there is wrong! The dataset in the data in the database!

Time:10-17

I will be out on the data from the database list a gridview, can be displayed on the page! No problem, then I transfer the data to the dataset, and then into the same database table of data in a dataset b (no data) is a new table, table b, then an error: the object reference not set to an instance of an object,
 
The DataSet ds=new DataSet ();
GridView1. The DataSource=ds;
String sqlStr2="insert into getMedicine (medicine_Id medicine_Name, medicine_Spec, medicine_Price) values ('" + ds. Tables [r]. "getMedicine" Rows [0]. The ToString () + "', '" + ds. Tables [r]." getMedicine "Rows [1]. The ToString () +"', '" + ds. Tables [r]. "getMedicine" Rows [2]. The ToString () + "', '" + ds. Tables [r]. "getMedicine" Rows [3]. The ToString () + "");";


Please everybody to help! Thank you very much!

CodePudding user response:

Don't sink! Everybody to help

CodePudding user response:

GridView1. The DataSource=ds;
Ds has no data, you must not go to see values
Ds. Tables [r]. "getMedicine" Rows [0]. The ToString ()

CodePudding user response:

Your ds or empty

CodePudding user response:

refer to the second floor it_gz_xi response:
GridView1. The DataSource=ds;
Ds has no data, you must not go to see values
Ds. Tables [r]. "getMedicine" Rows [0]. The ToString ()
oh oh that how to put the data in the gridview in the dataset

CodePudding user response:

The
reference 3 floor hands on the keyboard to knock very light response:
your ds or empty
ah how to do the gridview data into a dataset

CodePudding user response:

Handsome, the equal sign is generally the right assigned to the left

CodePudding user response:

You have the same table a and table b, column names?
If this is not the same as direct
for (int i=0; I & lt; DataGridView1. Rows. Count; I++)
{

String sqlStr2="insert into getMedicine (medicine_Id medicine_Name, medicine_Spec, medicine_Price) values ('" + DataGridView1. Rows [I] Cells [r]. "the column name" ToString () + "', '" +
DataGridView1. Rows [I] Cells [r]. "the column name" ToString () + "', '" + DataGridView1. Rows [I] Cells [r]." the column name "ToString () +"', '" + DataGridView1. Rows [I] Cells [r]. "the column name" ToString () + "");";
}

CodePudding user response:

refer to fifth floor MidDIE | 2 reply:
Quote: refer to the third floor hands on the keyboard to knock very light response:
your ds or empty
: : what to do with the data into a dataset of the gridview?


What are you going to assignment ds no value?
Or is the SQL statements below are you going to give his assignment? Pay attention to the language of the execution sequence, the debug will prompt you mistake

CodePudding user response:

refer to the eighth floor Xu Ziyao response:
Quote: refer to fifth floor MidDIE | 2 reply:

Quote: refer to the third floor hands on the keyboard to knock very light response:
your ds or empty
: : what to do with the data into a dataset of the gridview?


What are you going to assignment ds no value?
Or is the SQL statements below are you going to give his assignment? Pay attention to the language of the execution sequence, the debug will prompt you to error
the gridview has value, that is the ds=gridview1. The value is ok

CodePudding user response:

refer to the eighth floor Xu Ziyao response:
Quote: refer to fifth floor MidDIE | 2 reply:

Quote: refer to the third floor hands on the keyboard to knock very light response:
your ds or empty
: : what to do with the data into a dataset of the gridview?


What are you going to assignment ds no value?
Or is the SQL statements below are you going to give his assignment? Pay attention to the language of the execution sequence, the debug will prompt you to error
not value, is girdview. The datasource

CodePudding user response:

refer to 6th floor hands on the keyboard to knock very light response:
handsome, the equal sign is the assignment of the right side to the left of the
is that ds=the gridview. The datasource

CodePudding user response:

The dataset to assign you to the gridview value can be deposited in the database, rather than a new a new dataset, new, and you don't value assignment, when let is empty,
  • Related