|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataAdapter.Fill, ConstraintException, and Primary KeysDim daResult As SqlDataAdapter = New SqlDataAdapter Dim Result As DataSet = Nothing [code to set up the data adapter with a stored procedure, parameters, connection, etc.] daResult.MissingSchemaAction = MissingSchemaAction.AddWithKey daResult.Fill(Result, tableName) and SQL code in the called stored procedure: SELECT '2_FieldID' = table2.idfield FROM base_table LEFT JOIN (table1 INNER JOIN table2 ON table1.2_idfield = table2.idfield) ON base_table.idfield = table1.base_idfield where idfield is an IDENTITY(1, 1) PRIMARY KEY field on table2 and 2_idfield is a foreign key to it on table1. *However*, I don't get the ConstraintException when I make the SQL statement like this: SELECT '2_FieldID' = table1.2_idfield FROM base_table LEFT JOIN table1 ON base_table.idfield = table1.base_idfield nor do I get this error when I leave out the VB.NET line: daResult.MissingSchemaAction = MissingSchemaAction.AddWithKey I do need the MissingSchemaAction; I can fudge my stored procedures to avoid selecting the idfields directly, but I can't help but feel that I'm missing something here, especially since I'm using the same code in a lot of places and only running into the problem in a small handful of stored procedures which aren't, as far as I can tell, bases on tables with any different constraints than the unproblematic ones. (Is there something I should be looking for?) Thanks, Caitlin Shaw |
|||||||||||||||||||||||