Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataSet Tables Names
Message
From
16/09/2004 15:33:02
 
 
To
16/09/2004 14:12:56
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00943051
Message ID:
00943069
Views:
27
Bill,

In addition to Kevin's methodology, it can also be done by the use of further sub-classing of a strongly Typed DataSet.

Let me elaborate:

When you .Fill() a DataSet from a Stored Proc, ADO.NET names the tables as: table, Table1, Table2, etc. If you use pre-defined DataSets (.xsd schemas), then your DataSet needs to use these same TableNames (table, Table1, Table2, etc.) and if you generate a Typed DataSet from this (by right-clicking in the DataSet designer and toggle the "Generate DataSet"), the TableNames remain as table, Table1, Table2, etc. However, if you then further subclass your Typed DataSet, you can set properties to return the names that you want for your Tables, like this:
	[Serializable()]
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	[System.Diagnostics.DebuggerStepThrough()]
	[System.ComponentModel.ToolboxItem(true)]
	public class MyDataSet : GeneratedTypedDataSet
	{
		#region Constructor
		public MyDataSet(SerializationInfo info, StreamingContext context) : base(info, context)
		{
		}
		public MyDataSet()
		{
		}
		#endregion

		#region Properties
		[System.ComponentModel.Browsable(false)]
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
		public tableDataTable MyTableOne
		{
			get {return this.table;}
		}
		[System.ComponentModel.Browsable(false)]
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
		public Table1DataTable MyTableTwo
		{
			get {return this.Table1;}
		}
		[System.ComponentModel.Browsable(false)]
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
		public Table2DataTable MyTableThree
		{
			get {return this.Table2;}
		}
		#endregion
	}
And then you would use the MyDataSet class for your DataSet rather than using the GeneratedTypedDataSet. I know it looks like a lot of work and extra steps to go through, but it's really not bad and working with Typed DataSets definitely has it's advantages. (My opinion anyway)

~~Bonnie



>When querying SQL Server via a stored proc that returns multiple result sets, is it possible to specify the tables' names? And is this possible from the SQL Server side?
>
>Thanks,
>Bill
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform