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 the following
query:
SELECT Material.*, Color.Color AS Color
FROM Material INNER JOIN
Color ON Color.ColorID = Material.fkColo rID
FillSchema does not obtain MaterialID, the primary key of the Material
table, as the primary key, even though its uniqueness is not affected
at all by the JOIN with Color.
It is, of course, possible to manually configure primary keys.
However, this is not as desirable as the automated FillSchema approach.
Is this just the way things are, or is there some trick that I am
missing?
Thanks,
Aaron 3 5206
that is because after a join there is no longer a "primary key" on the
table... you'd have the same problem on the server side too in SQL server...
when you alter the DML through the join it ignores keys...
"Aaron" <od*********@ho tmail.comwrote in message
news:11******** **************@ 74g2000cwt.goog legroups.com...
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 the following
query:
SELECT Material.*, Color.Color AS Color
FROM Material INNER JOIN
Color ON Color.ColorID = Material.fkColo rID
FillSchema does not obtain MaterialID, the primary key of the Material
table, as the primary key, even though its uniqueness is not affected
at all by the JOIN with Color.
It is, of course, possible to manually configure primary keys.
However, this is not as desirable as the automated FillSchema approach.
Is this just the way things are, or is there some trick that I am
missing?
Thanks,
Aaron
Aaron,
You be aware that AFAIK a joined table not meant to be updated using that.
Cor
"Aaron" <od*********@ho tmail.comschree f in bericht
news:11******** **************@ 74g2000cwt.goog legroups.com...
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 the following
query:
SELECT Material.*, Color.Color AS Color
FROM Material INNER JOIN
Color ON Color.ColorID = Material.fkColo rID
FillSchema does not obtain MaterialID, the primary key of the Material
table, as the primary key, even though its uniqueness is not affected
at all by the JOIN with Color.
It is, of course, possible to manually configure primary keys.
However, this is not as desirable as the automated FillSchema approach.
Is this just the way things are, or is there some trick that I am
missing?
Thanks,
Aaron
Interesting (although mostly useless) loophole:
If a tables primary keys are also the foreign key columns (used to form
the joins) then the primary keys will populate correctly. I discovered
this on accident. Weird, huh?
I am also still on VS 2003.
Aaron This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Victor |
last post by:
Hello there,
I have a module in VB.NET (ASP.NET) and on top I declare the
SqlConnection and the SqlDataAdapter.
Like:
Module AccessDB
Dim sqlCmd As New SqlCommand
Dim conAanvraag As New
|
by: Matt Jensen |
last post by:
Howdy
Fairly simple question I think, I presume the answer is no it can't be
reused for 2 *SELECT* statements, but just hoping for clarification. Just
asking in the interests of trying to minimise code.
i.e. if the SqlDataAdapter uses a connection to the one database for a
select statement and I want to do a second select statement on exactly the
same database, can I reuse the SqlDataAdapter?
I ask because I want to put both 'select'...
|
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 others inlude the corrrect information.
The code we used is the following:
|
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, SchemaType.Source, "tbl1")
....
|
by: downwitch |
last post by:
Hi,
I'm having trouble getting data in ADO.Net recordsets. (VS 2005, SQL
Server 2005). All my rowsets come back empty--whether sourced from
queries or stored procs--despite ODBC connections with the same user
credentials (two different UID/PWDs tried) returning existing data
without a problem (i.e. it's not a SQL security problem).
With code like
| |
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 :)
|
by: =?Utf-8?B?QWxleCBLLg==?= |
last post by:
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);
|
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
|
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 set to true.
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |