ee_lcpaa
asked on
No row return after calling the fillschema method
The DB server used is MySQL 5.7.16.
I have a program using MySQL .Net connector. I notice that i can read data into a dataset in using the dataadapter's Fill method.
However, if I call the fillschema method first and then call the full method later. Nothing is returned in the dataset (I.e. Row count is zero) with the same SELECT query used.
Pls advise the possible causes. Thanks.
I have a program using MySQL .Net connector. I notice that i can read data into a dataset in using the dataadapter's Fill method.
However, if I call the fillschema method first and then call the full method later. Nothing is returned in the dataset (I.e. Row count is zero) with the same SELECT query used.
Pls advise the possible causes. Thanks.
ASKER
Sorry, there is a typo in my previous message. I am using the Fill method, not Full method.
Try this from MSDN- FillSchema After Fill Method.
Ref-https://msdn.microsoft.com/en-us/library/ms135707.aspx
public static DataSet GetCustomerData(string dataSetName,
string connectionString)
{
DataSet dataSet = new DataSet(dataSetName);
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter(
"SELECT CustomerID, CompanyName, ContactName FROM dbo.Customers", connection);
DataTableMapping mapping = adapter.TableMappings.Add("Table", "Customers");
mapping.ColumnMappings.Add("CompanyName", "Name");
mapping.ColumnMappings.Add("ContactName", "Contact");
connection.Open();
adapter.FillSchema(dataSet, SchemaType.Mapped);
adapter.Fill(dataSet);
return dataSet;
}
}
Ref-https://msdn.microsoft.com/en-us/library/ms135707.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DataSet.Tables[0].Rows.Cou
FillSchema method retrieves the DB schema using the SelectCommand. It creates a DataTable with all the columns to the DataColumnCollection and configures the necessary DataColumn properties. This method doesn't fill the datatable with rows, it only applies the schema.
So it is basically we get empty table with only column names and constraints.
We need to use the Fillmethod to fill the rows. There is no FULL Method available.
Hope it helps !