473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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(strSQL);
cmd.Connection = cn;
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
int ret = adapter.Fill(ds);
adapter.FillSchema(ds, SchemaType.Mapped, "Table");
adapter.FillSchema(ds, SchemaType.Mapped, "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 5137
(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(strSQL);
cmd.Connection = cn;
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
int ret = adapter.Fill(ds);
adapter.FillSchema(ds, SchemaType.Mapped, "Table");
adapter.FillSchema(ds, SchemaType.Mapped, "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***@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.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"
OleDbConnection cn = new OleDbConnection(strConnection);
OleDbCommand cmd = new OleDbCommand(strSQL);
cmd.Connection = cn;
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
int ret = adapter.Fill(ds);
adapter.FillSchema(ds, SchemaType.Mapped, "Table");
adapter.FillSchema(ds, SchemaType.Mapped, "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***@discussions.microsoft.comsaid:
(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***@discussions.microsoft.comsaid:
(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 OleDbDataAdapter 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 OleDbDataAdapter, it is recommended that you
specify a MissingSchemaAction 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***@discussions.microsoft.comwrote in message
news:0B**********************************@microsof t.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***@discussions.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 #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 UniqueConstraint 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 OleDbDataAdapter 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 OleDbDataAdapter, it is recommended that you
specify a MissingSchemaAction 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***@discussions.microsoft.comwrote in message
news:0B**********************************@microsof t.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***@discussions.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 #7
Liz

have you queried microsoft.public.dotnet.framework.adonet ? I don't know
anything about the NG but it has the right name .... :)
"Alex K." <Al***@discussions.microsoft.comwrote in message
news:ED**********************************@microsof t.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 UniqueConstraint 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 OleDbDataAdapter 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 OleDbDataAdapter, it is recommended that
you
specify a MissingSchemaAction 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***@discussions.microsoft.comwrote in message
news:0B**********************************@microso ft.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***@discussions.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***@discussions.microsoft.comwrote:
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
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...
5
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...
1
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...
0
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...
3
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...
1
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...
0
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...
1
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,...
0
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.