If you use a batch SQL statement to retrieve multiple tables and fill
a DataSet, the first table is named using the table name specified to
the Fill method. Subsequent tables are named using the name specified
to the Fill method plus a number starting from one and incrementing by
one. For example, if you were to run the following code: MSDN
So the code will be
adap = new SqlDataAdapter("SELECT * FROM Employee; Select * from Shift; select * from Has_Shift", mycon);
// second table name will be Employee +1
adap.TableMappings.Add("Employee1", "Shift");
// second table name will be Employee +2
adap.TableMappings.Add("Employee2", "Has_Shift");
// give Table name as below
adap.Fill(ds, "Employee");
DataRow newRow = ds.Tables["Employee"].NewRow();
newRow["Name"] = textBox1.Text;
ds.Tables["Employee"].Rows.Add(newRow);
adap.Update(ds);
mycon.Close();
Since here we gave "Employee" as table name in Fill method, first table will be "Employee" and second will be "Employee1" and third will be "Employee2"
Since you haven't given any table name your table names will be "Table", "Table1", "Table2" ...
You can map them to correct name
adap.TableMappings.Add("Table", "Employee");
adap.TableMappings.Add("Table1", "Shift");
adap.TableMappings.Add("Table2", "Has_Shift");
and rest of the code will be
adap.Fill(ds);
DataRow newRow = ds.Tables["Employee"].NewRow();
newRow["Name"] = textBox1.Text;
ds.Tables["Employee"].Rows.Add(newRow);
adap.Update(ds);
mycon.Close();
ds?adap.Fill(ds);dswere null).