What's wrong...?
-
My sql query looks like select t1.code, t2.name from tab1 t1, tab2 t2 where t1.code=t2.code Then I call DataAdapter.Fill(DatasetXSD); no errors occured but DatasetXSD is empty, and when I run the same query in PL/SQL Developer everething works fine... Maybe some one can tell me anoter way to fill Dataset from multiple tables correctly? xedom developers team
I already answered your question below. You must set up table mappings. See the
DataAdapter.TableMappings
property documentation in the .NET Framework SDK. When you use theDataAdapter
designer in VS.NET, it does this for you.Microsoft MVP, Visual C# My Articles
-
I already answered your question below. You must set up table mappings. See the
DataAdapter.TableMappings
property documentation in the .NET Framework SDK. When you use theDataAdapter
designer in VS.NET, it does this for you.Microsoft MVP, Visual C# My Articles
Thanx, but I tried to use mapping and got the same effect...I even create dataset fom a blank xsd file, and I create a table with 9 columns (like my query returns) and even names and types in dataset.xsd and query result are the same, but I still got an empty Dataset. Could you give me some link for mapping usage? Maybe I do somthing wrong with it.. xedom developers team
-
Thanx, but I tried to use mapping and got the same effect...I even create dataset fom a blank xsd file, and I create a table with 9 columns (like my query returns) and even names and types in dataset.xsd and query result are the same, but I still got an empty Dataset. Could you give me some link for mapping usage? Maybe I do somthing wrong with it.. xedom developers team
I didn't say create a typed
DataSet
(which is still a good idea), I said look at the documentation for theDataAdapter.TableMappings
property. Even with a typedDataSet
, theDataAdapter
has to know how to map tables into yourDataSet
(typed or read in from a schema - whatever the case may be). Open the .NET Framework SDK documentation (via the SDK start menu group or VS.NET) and typeDataAdapter.TableMappings
. The .NET Framework SDK includes great documentation, but you have to read it. In this case (and in many other cases), there's even an example.Microsoft MVP, Visual C# My Articles
-
I didn't say create a typed
DataSet
(which is still a good idea), I said look at the documentation for theDataAdapter.TableMappings
property. Even with a typedDataSet
, theDataAdapter
has to know how to map tables into yourDataSet
(typed or read in from a schema - whatever the case may be). Open the .NET Framework SDK documentation (via the SDK start menu group or VS.NET) and typeDataAdapter.TableMappings
. The .NET Framework SDK includes great documentation, but you have to read it. In this case (and in many other cases), there's even an example.Microsoft MVP, Visual C# My Articles
ok thank you very much...I've red all samples(can't say them are very usefull) but it still does not work... Let me tell you for what I need to work with dataset in that way: I now developing ASP.NET Application with crystal reports, to use push model I need to add DataSet maunally like xsd file. and then in my application I filling this xsd dataset. xedom developers team
-
ok thank you very much...I've red all samples(can't say them are very usefull) but it still does not work... Let me tell you for what I need to work with dataset in that way: I now developing ASP.NET Application with crystal reports, to use push model I need to add DataSet maunally like xsd file. and then in my application I filling this xsd dataset. xedom developers team
Lets say the
DataSet
has a structure like so:<DataSet1>
<t1>
<!-- Fields -->
</t1>
<t1>
<!-- Fields -->
</t1>
<t2>
<!-- Fields -->
</t2>
<t2>
<!-- Fields -->
</t2>
</DataSet1>Then before you execute
DataAdapter.Fill
, executing code similar to the following:dataAdapter1.TableMappings.Add("Table", "t1");
dataAdapter1.TableMappings.Add("Table1", "t2");
dataAdapter1.Fill(myDataSet1);Now, since you're using table aliases, those will be the table names used in the output so if your
DataTable
names use the aliases, you shouldn't need this. ADataTableMapping
maps the source table name to a destination table name. Trust me - it's the reason yourDataSet
is empty. You must make sure that your table names in the result sets match up with the table names in theDataSet
, whether thatDataSet
is typed, programmatically created, or read-in from an XSD.Microsoft MVP, Visual C# My Articles
-
Lets say the
DataSet
has a structure like so:<DataSet1>
<t1>
<!-- Fields -->
</t1>
<t1>
<!-- Fields -->
</t1>
<t2>
<!-- Fields -->
</t2>
<t2>
<!-- Fields -->
</t2>
</DataSet1>Then before you execute
DataAdapter.Fill
, executing code similar to the following:dataAdapter1.TableMappings.Add("Table", "t1");
dataAdapter1.TableMappings.Add("Table1", "t2");
dataAdapter1.Fill(myDataSet1);Now, since you're using table aliases, those will be the table names used in the output so if your
DataTable
names use the aliases, you shouldn't need this. ADataTableMapping
maps the source table name to a destination table name. Trust me - it's the reason yourDataSet
is empty. You must make sure that your table names in the result sets match up with the table names in theDataSet
, whether thatDataSet
is typed, programmatically created, or read-in from an XSD.Microsoft MVP, Visual C# My Articles
Ok, thnak for your information. But I think the problem is that when I run this code: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); DataSet ds = new DataSet(); da.Fill(ds); Everything goes fine. But when I've just to use my xsd datset like this: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); dsXSD = new DataSet(); da.Fill(dsXSD); It returns an empty dataset, only columns header are avialinle to be shown in the datagrid. xedom developers team
-
Ok, thnak for your information. But I think the problem is that when I run this code: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); DataSet ds = new DataSet(); da.Fill(ds); Everything goes fine. But when I've just to use my xsd datset like this: OracleDataAdapter da = new OracleDataAdapter(); da = new OracleDataAdapter(sql, con); dsXSD = new DataSet(); da.Fill(dsXSD); It returns an empty dataset, only columns header are avialinle to be shown in the datagrid. xedom developers team
Look at the "generic"
DataSet
generated with the first statement. See how the tables are named. Now name the tables in your typedDataSet
the same way, or use aDataTableMapping
as I've said several times above. If the table names in the result set don't match up with the names of a configuredDataSet
, it will remain empty.Microsoft MVP, Visual C# My Articles
-
Look at the "generic"
DataSet
generated with the first statement. See how the tables are named. Now name the tables in your typedDataSet
the same way, or use aDataTableMapping
as I've said several times above. If the table names in the result set don't match up with the names of a configuredDataSet
, it will remain empty.Microsoft MVP, Visual C# My Articles
Thnank you! It works now!!! I've just renamed dataset tebles...but I still don't understand how DataTableMapping works, but anyway thanx for you advises. Crystal Reports not so suitable technology as for me... xedom developers team
-
Thnank you! It works now!!! I've just renamed dataset tebles...but I still don't understand how DataTableMapping works, but anyway thanx for you advises. Crystal Reports not so suitable technology as for me... xedom developers team
leTaon wrote: Crystal Reports not so suitable technology I agree. While the user's experience is great with Crystal, the developer goes through literal hell trying to get it working correctly.
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat! -
Thnank you! It works now!!! I've just renamed dataset tebles...but I still don't understand how DataTableMapping works, but anyway thanx for you advises. Crystal Reports not so suitable technology as for me... xedom developers team
Just look at the class name: table mappings. If you look at the documentation, it maps a source table name to a destination table name, so that if the table name in the result set the
DataAdapter
gets is different from what you want it to be in a configuredDataSet
, it will map it.Microsoft MVP, Visual C# My Articles