473,546 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FillSchema

Hi all

I noticed that if Select stmt returns dataset containing two tables,
executing FillShema only populates schema info for first table only.

Simple test: (.NET 2.0)

....
string strSQL = "Select * from tableA select * from tableB"
OleDbConnection cn = new OleDbConnection (strConnection) ;
OleDbCommand cmd = new OleDbCommand(st rSQL);
cmd.Connection = cn;
OleDbDataAdapte r adapter = new OleDbDataAdapte r(cmd);
DataSet ds = new DataSet();
int ret = adapter.Fill(ds );
adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table");
adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table1");

Everything is working fine, except that for second table, shema info is not
set. In particular, MaxLength attribute of all string fields in second table
is always -1. In the first table, MaxLength shows real max length of a field.

Is there any way to fill schema for second table (and other tables if any)?

Thank you
Alex



Nov 29 '07 #1
8 5149
(just to revive this thread:)
Hey, C# experts, where are you?...

"Alex K." wrote:
Hi all

I noticed that if Select stmt returns dataset containing two tables,
executing FillShema only populates schema info for first table only.

Simple test: (.NET 2.0)

...
string strSQL = "Select * from tableA select * from tableB"
OleDbConnection cn = new OleDbConnection (strConnection) ;
OleDbCommand cmd = new OleDbCommand(st rSQL);
cmd.Connection = cn;
OleDbDataAdapte r adapter = new OleDbDataAdapte r(cmd);
DataSet ds = new DataSet();
int ret = adapter.Fill(ds );
adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table");
adapter.FillSch ema(ds, SchemaType.Mapp ed, "Table1");

Everything is working fine, except that for second table, shema info is not
set. In particular, MaxLength attribute of all string fields in second table
is always -1. In the first table, MaxLength shows real max length of a field.

Is there any way to fill schema for second table (and other tables if any)?

Thank you
Alex


Nov 30 '07 #2
Liz
string strSQL = "Select * from tableA select * from tableB"
where's the semi-colon?

string strSQL = "SELECT * FROM tableA; SELECT * FROM tableB"

I would have thought you'd get a SQL Exception ....
"Alex K." <Al***@discussi ons.microsoft.c omwrote in message
news:C9******** *************** ***********@mic rosoft.com...
(just to revive this thread:)
Hey, C# experts, where are you?...

"Alex K." wrote:
>Hi all

I noticed that if Select stmt returns dataset containing two tables,
executing FillShema only populates schema info for first table only.

Simple test: (.NET 2.0)

...
string strSQL = "Select * from tableA select * from tableB"
OleDbConnectio n cn = new OleDbConnection (strConnection) ;
OleDbCommand cmd = new OleDbCommand(st rSQL);
cmd.Connecti on = cn;
OleDbDataAdapt er adapter = new OleDbDataAdapte r(cmd);
DataSet ds = new DataSet();
int ret = adapter.Fill(ds );
adapter.FillSc hema(ds, SchemaType.Mapp ed, "Table");
adapter.FillSc hema(ds, SchemaType.Mapp ed, "Table1");

Everything is working fine, except that for second table, shema info is
not
set. In particular, MaxLength attribute of all string fields in second
table
is always -1. In the first table, MaxLength shows real max length of a
field.

Is there any way to fill schema for second table (and other tables if
any)?

Thank you
Alex



Nov 30 '07 #3
On 2007-11-30 09:18:01 -0800, Alex K. <Al***@discussi ons.microsoft.c omsaid:
(just to revive this thread:)
Hey, C# experts, where are you?...
For what it's worth, I didn't see anything in your question that had
anything specific to do with C#.

It appears to be primarily a database question. Granted, there are
several C# experts following this newsgroup who _also_ are database
experts, and they do in fact sometimes answer database questions here.

But if you've got a database question and you really really need an
answer, you're probably better off posting the question to a database
newsgroup (even one that still is specific to .NET, if appropriate).

Pete

Nov 30 '07 #4
Peter,

the question is about how C# function FillSchema works, not about how
database works. On database side, I have no problems at all - of course, both
db tables have all their properties in place.

When you create a dataset using Select stmt, and then look into datatables
that are contained in that dataset, you will see that MaxLength property is
not populated unless you execute FillSchema on that dataset.

My question is: why FillSchema call only populates schema properties (e.g.
MaxLength) only for the first datatable in dataset?

Thank you for your response.
"Peter Duniho" wrote:
On 2007-11-30 09:18:01 -0800, Alex K. <Al***@discussi ons.microsoft.c omsaid:
(just to revive this thread:)
Hey, C# experts, where are you?...

For what it's worth, I didn't see anything in your question that had
anything specific to do with C#.

It appears to be primarily a database question. Granted, there are
several C# experts following this newsgroup who _also_ are database
experts, and they do in fact sometimes answer database questions here.

But if you've got a database question and you really really need an
answer, you're probably better off posting the question to a database
newsgroup (even one that still is specific to .NET, if appropriate).

Pete

Dec 1 '07 #5
Liz

Alex, here's your answer, direct from the docs:

Note
If the FillSchema method of the OleDbDataAdapte r object is called for a
command that returns multiple result sets, only the schema information from
the first result set is returned. When returning schema information for
multiple result sets using the OleDbDataAdapte r, it is recommended that you
specify a MissingSchemaAc tion of AddWithKey and obtain the schema
information when calling the Fill method.

Look for the topic:

"Adding Existing Constraints to a DataSet"

Liz

"Alex K." <Al***@discussi ons.microsoft.c omwrote in message
news:0B******** *************** ***********@mic rosoft.com...
Peter,

the question is about how C# function FillSchema works, not about how
database works. On database side, I have no problems at all - of course,
both
db tables have all their properties in place.

When you create a dataset using Select stmt, and then look into datatables
that are contained in that dataset, you will see that MaxLength property
is
not populated unless you execute FillSchema on that dataset.

My question is: why FillSchema call only populates schema properties (e.g.
MaxLength) only for the first datatable in dataset?

Thank you for your response.
"Peter Duniho" wrote:
>On 2007-11-30 09:18:01 -0800, Alex K. <Al***@discussi ons.microsoft.c om>
said:
(just to revive this thread:)
Hey, C# experts, where are you?...

For what it's worth, I didn't see anything in your question that had
anything specific to do with C#.

It appears to be primarily a database question. Granted, there are
several C# experts following this newsgroup who _also_ are database
experts, and they do in fact sometimes answer database questions here.

But if you've got a database question and you really really need an
answer, you're probably better off posting the question to a database
newsgroup (even one that still is specific to .NET, if appropriate).

Pete


Dec 1 '07 #6
Thank you, Liz

I have read this topic in the HELP. It didn't help much: I tried. When I do
this, it is trying to add UniqueConstrain t which causes another problems with
my query (real query, not the example I posted). Error handling routine grows
crazy.

I still hope to find simple and elegant solution to populate schema info in
multi-table dataset ... :-|

Thanks again.
Alex
"Liz" wrote:
>
Alex, here's your answer, direct from the docs:

Note
If the FillSchema method of the OleDbDataAdapte r object is called for a
command that returns multiple result sets, only the schema information from
the first result set is returned. When returning schema information for
multiple result sets using the OleDbDataAdapte r, it is recommended that you
specify a MissingSchemaAc tion of AddWithKey and obtain the schema
information when calling the Fill method.

Look for the topic:

"Adding Existing Constraints to a DataSet"

Liz

"Alex K." <Al***@discussi ons.microsoft.c omwrote in message
news:0B******** *************** ***********@mic rosoft.com...
Peter,

the question is about how C# function FillSchema works, not about how
database works. On database side, I have no problems at all - of course,
both
db tables have all their properties in place.

When you create a dataset using Select stmt, and then look into datatables
that are contained in that dataset, you will see that MaxLength property
is
not populated unless you execute FillSchema on that dataset.

My question is: why FillSchema call only populates schema properties (e.g.
MaxLength) only for the first datatable in dataset?

Thank you for your response.
"Peter Duniho" wrote:
On 2007-11-30 09:18:01 -0800, Alex K. <Al***@discussi ons.microsoft.c om>
said:

(just to revive this thread:)
Hey, C# experts, where are you?...

For what it's worth, I didn't see anything in your question that had
anything specific to do with C#.

It appears to be primarily a database question. Granted, there are
several C# experts following this newsgroup who _also_ are database
experts, and they do in fact sometimes answer database questions here.

But if you've got a database question and you really really need an
answer, you're probably better off posting the question to a database
newsgroup (even one that still is specific to .NET, if appropriate).

Pete



Dec 1 '07 #7
Liz

have you queried microsoft.publi c.dotnet.framew ork.adonet ? I don't know
anything about the NG but it has the right name .... :)
"Alex K." <Al***@discussi ons.microsoft.c omwrote in message
news:ED******** *************** ***********@mic rosoft.com...
Thank you, Liz

I have read this topic in the HELP. It didn't help much: I tried. When I
do
this, it is trying to add UniqueConstrain t which causes another problems
with
my query (real query, not the example I posted). Error handling routine
grows
crazy.

I still hope to find simple and elegant solution to populate schema info
in
multi-table dataset ... :-|

Thanks again.
Alex
"Liz" wrote:
>>
Alex, here's your answer, direct from the docs:

Note
If the FillSchema method of the OleDbDataAdapte r object is called for a
command that returns multiple result sets, only the schema information
from
the first result set is returned. When returning schema information for
multiple result sets using the OleDbDataAdapte r, it is recommended that
you
specify a MissingSchemaAc tion of AddWithKey and obtain the schema
information when calling the Fill method.

Look for the topic:

"Adding Existing Constraints to a DataSet"

Liz

"Alex K." <Al***@discussi ons.microsoft.c omwrote in message
news:0B******* *************** ************@mi crosoft.com...
Peter,

the question is about how C# function FillSchema works, not about how
database works. On database side, I have no problems at all - of
course,
both
db tables have all their properties in place.

When you create a dataset using Select stmt, and then look into
datatables
that are contained in that dataset, you will see that MaxLength
property
is
not populated unless you execute FillSchema on that dataset.

My question is: why FillSchema call only populates schema properties
(e.g.
MaxLength) only for the first datatable in dataset?

Thank you for your response.
"Peter Duniho" wrote:

On 2007-11-30 09:18:01 -0800, Alex K.
<Al***@discuss ions.microsoft. com>
said:

(just to revive this thread:)
Hey, C# experts, where are you?...

For what it's worth, I didn't see anything in your question that had
anything specific to do with C#.

It appears to be primarily a database question. Granted, there are
several C# experts following this newsgroup who _also_ are database
experts, and they do in fact sometimes answer database questions here.

But if you've got a database question and you really really need an
answer, you're probably better off posting the question to a database
newsgroup (even one that still is specific to .NET, if appropriate).

Pete




Dec 1 '07 #8
On Sat, 01 Dec 2007 06:43:00 -0800, Alex K.
<Al***@discussi ons.microsoft.c omwrote:
Thank you, Peter

When we talk about databases, we mean different things. What I call
database, is a SQL Server database, Oracle database, MS Jet database etc.
What you call database is just .NET database layer, database-oriented
part of .NET function set.
No, it's not "just" that. But yes, I do include the .NET database layer.
Yes, you are right when you are saying that FillSchema question is more
about .NET database layer. But as I told you, it has nothing to do with
databases themselves because not SQL Server, nor Oracle, nor Jet have
function called "FillSChema ".
So are you saying that any "C# expert" should be able to answer your
question? If not, I don't see why you are debating this at all. If so,
why does being an expert in C# imply knowledge of database-related topics?
[...]
When readers are posting questions about sockets, graphics or XML,
(examples from current page), they are not asking about C# using
your meaning of the word.
I readily acknowledge the large amount of traffic in this newsgroup that
is theoretically off-topic. My point is not to argue that you shouldn't
have asked your question here, and had you read what I'd written you'd
understand that.

My point _is_ that your impatience with the people in this newsgroup is
ill-placed. While you're free to ask the question here, you have no
reason to expect it would be answered. That's true for any question, of
course, but even more so for something as esoteric as the issue you're
running into.
[...] With your
permission or not, I will continue to post here all questions that I may
have about using C# in real world tasks
Again, you clearly have not bothered to read what I wrote. This isn't
about what you _may_ post here. It's about unreasonable expectations of
what sort of response you might get. Posting your original question
wasn't a problem at all. Acting like a "C# expert" ought to know the
answer to your question is a problem.

Furthermore, it's only a problem inasmuch as it sets you up for
disappointment. I'm not trying to take you task for doing something
wrong, as it seems like you think I am doing. Where does "with your
permission or not" come from? I'm not telling you what you may or may not
do. I'm just trying to be helpful.

If you don't appreciate the help, fine. But I don't see why you feel the
need to argue about what a "database question" is, and there's certainly
no need for the offense you appear to have taken regarding my motives.

Pete
Dec 1 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
2019
by: Chris | last post by:
Hi I need to pass the entries in a text file to corresponding tables in a database. Can I pass the entire text file to a stored procedure or can I write a VB.NET procedure to pharse the file and pass the data to the database? This is a sample of the text fil 1120,011522169050,01,+0000001,031221,0005.95,2003,8331308,2003122...
5
7427
by: Edward Mitchell | last post by:
I have a database with text string fields defined by varchar(nnn). When I request from the user the text from a textbox, I'd like to set the maximum number of characters in the textbox to the "nnn" that was used in the varchar(...) statement in the field definition. i.e. Field1 varchar(25) NOT NULL and in the .aspx file: ...
1
3277
by: Programmer | last post by:
Hi All Here is my problem I'm using a SQLDataAdapter and DataSet I use the method FillSchema(myDataset, SchemaType.Source) The problem is that when i Check the default Values of the Dataset i can see that the DefaultValue of the columns is system.dbnull!!!! But in SQL Server i have put as default values in a bigint field the '0' and
0
1280
by: Andrea Temporin | last post by:
We are working on a Db Oracle accessed by Oledb. We get connection using MSDAORA.1 provider ad ORACLE 9.2 drivers on the PC. We create datatables associated to the tables on the db, using FillSchema. Some tables don't include primary key, even if they have the correct structure on the db. The datatables without primary key are few. The...
3
5197
by: Aaron | last post by:
Hi, The SqlDataAdapter.FillSchema method will automatically setup things like the primary keys, auto increment, etc based on the settings on the SQL Server. However, if you create a datatable using the SQL statement that joins together data from multiple data tables, then FillSchema does not work (as much? at all??). For example, if I use...
1
5209
by: Rich | last post by:
Hello, I want to use a dataAdapter to insert rows into a table on a sql server DB. I understand that the DataAdapter will automatically handle concurrency issues. So first I have to get a table to insert a row into. I have been doing this: da.SelectCommand = New SqlCommand("Select * from tbl1", conn) da.FillSchema(ds,...
0
1428
by: ReneMarxis | last post by:
Hello all first let me say i start getting an idea on how powerful data binding is. You can hold your code as short as possible and also have a pretty big flexibility. Also thanks to this great community here, without you i bet many of us would not succeed that fast. So now to my problem :)
1
1825
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm using the fillowing line: DataTable dt=null; da.FillSchema(dt,SchemaType.Source); well, it's pulling in extra columns from another table. anybody have any ideas? thanks, rodchar
0
1179
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm using vs.net2005 to to retrieve records, via a stored procedure, from sql server 2005 table. the primary key is set properly. but when i use the fillschema(...) method the .Unique and .ReadOnly properties are still set to false. now i tried the same experiment with a northwind table and it worked fine. both properties were...
0
7507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7698
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7794
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1922
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.