J
JimM
I'm using a stored procedure to retrieve hierarchical data from a database
for read only use. The stored procedure is:
CREATE PROC GetStringTable(@Token int) AS
SELECT * FROM StringTable WHERE Token = @Token
SELECT * FROM StringTableDetail WHERE Token = @Token"
When I use the "design surface" of the data access component to generate the
SqlDataAdapter (after setting the TableMappings manually) I can set the
Parameter value @Token with no problem.
However I'd like to code this without the design surface (with everything
local so the function can be shared/static). When I set the code:
Dim da As New SqlDataAdapter("GetStringTable", New
SqlConnection(ConnectString))
da.SelectCommand.CommandType = CommandType.StoredProcedure
da.TableMappings.Add("Table", "StringTable")
da.TableMappings.Add("Table1", "StringTableDetail")
da.SelectCommand.Parameters("@Token").Value = token
at runtime it fails, complaining that there is no parameter @Token in the
collection. Sure enough, the da.SelectCommand.Parameters collection is
initialized (not Nothing/null), but it contains zero items.
Is there any way to configure this DataAdapter to handle the multiple tables
with Parameters?
--- Jim ---
for read only use. The stored procedure is:
CREATE PROC GetStringTable(@Token int) AS
SELECT * FROM StringTable WHERE Token = @Token
SELECT * FROM StringTableDetail WHERE Token = @Token"
When I use the "design surface" of the data access component to generate the
SqlDataAdapter (after setting the TableMappings manually) I can set the
Parameter value @Token with no problem.
However I'd like to code this without the design surface (with everything
local so the function can be shared/static). When I set the code:
Dim da As New SqlDataAdapter("GetStringTable", New
SqlConnection(ConnectString))
da.SelectCommand.CommandType = CommandType.StoredProcedure
da.TableMappings.Add("Table", "StringTable")
da.TableMappings.Add("Table1", "StringTableDetail")
da.SelectCommand.Parameters("@Token").Value = token
at runtime it fails, complaining that there is no parameter @Token in the
collection. Sure enough, the da.SelectCommand.Parameters collection is
initialized (not Nothing/null), but it contains zero items.
Is there any way to configure this DataAdapter to handle the multiple tables
with Parameters?
--- Jim ---