G
Guest
Hi,
I'm having trouble using a parameters with the SelectCommand of an
OleDBDataAdapter. The situation is this...
1) I'm populating a DataSet that has three OleDBDataAdapters that feed it.
The Tables that they feed are table R1, R1History, and R1Allocations. The
R1 table is the main table. It has a 1 to many relationship with the other
two tables. All threee OleDBDataAdapters are read-only (no Delete, Update,
or Insert commands).
2) The SelectCommand for the OleDBDataAdapter that retrieves R1 has a parm.
The CommandText is...
?oleDbDataAdapter1.SelectCommand.CommandText
"Select * from R1 INNER JOIN RWeeks ON RDate = DayDate WHERE PeriodId = ?"
3) My code that calculates "period" and sets the parm seems to work.
?oleDbDataAdapter1.SelectCommand.Parameters(0).Value
200544 {Integer}
[Integer]: 200544 {Integer}
200544 is the correct value
4) I don't get any exceptions when oleDbDataAdapter.Fill is called, but I
don't get any records either. I know there are records because I ran the
"same" Select command in the Query Analyzer (SQL Server 2000 is the Db).
Select * from R1 INNER JOIN RWeeks ON RDate = DayDate WHERE PeriodId = 200544
returns one row, which is the correct answer.
Any suggestions / observations? BTW, I'm using the OleDbDataAdapter because
the parent form was created using the Data Form Wizard and it did the
original selection of the components to use. I'm extending this form. I'm
considering changing everything to use SqlDataAdapters, but I'd rather not if
I can make this work.
One more thing, I don't explicitly map all the fields that the query
returns. The "MissingMapping" property of the DataAdapter is set to
"Passthrough", Missing Schema is set to "Add".
Thanks for your help.
Steve
I'm having trouble using a parameters with the SelectCommand of an
OleDBDataAdapter. The situation is this...
1) I'm populating a DataSet that has three OleDBDataAdapters that feed it.
The Tables that they feed are table R1, R1History, and R1Allocations. The
R1 table is the main table. It has a 1 to many relationship with the other
two tables. All threee OleDBDataAdapters are read-only (no Delete, Update,
or Insert commands).
2) The SelectCommand for the OleDBDataAdapter that retrieves R1 has a parm.
The CommandText is...
?oleDbDataAdapter1.SelectCommand.CommandText
"Select * from R1 INNER JOIN RWeeks ON RDate = DayDate WHERE PeriodId = ?"
3) My code that calculates "period" and sets the parm seems to work.
?oleDbDataAdapter1.SelectCommand.Parameters(0).Value
200544 {Integer}
[Integer]: 200544 {Integer}
200544 is the correct value
4) I don't get any exceptions when oleDbDataAdapter.Fill is called, but I
don't get any records either. I know there are records because I ran the
"same" Select command in the Query Analyzer (SQL Server 2000 is the Db).
Select * from R1 INNER JOIN RWeeks ON RDate = DayDate WHERE PeriodId = 200544
returns one row, which is the correct answer.
Any suggestions / observations? BTW, I'm using the OleDbDataAdapter because
the parent form was created using the Data Form Wizard and it did the
original selection of the components to use. I'm extending this form. I'm
considering changing everything to use SqlDataAdapters, but I'd rather not if
I can make this work.
One more thing, I don't explicitly map all the fields that the query
returns. The "MissingMapping" property of the DataAdapter is set to
"Passthrough", Missing Schema is set to "Add".
Thanks for your help.
Steve