Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Hi, I am having problem to read data from the datasource through the OledbDataAdapter as shown in the code below:
Let say I have a table "TableB" in dataset "dset", with the data of "000" and "001" in "col1" column. I expected in the for loop below, the "TableA" will be filled with the data extracted out from the database where AData.SN = 001 (in first loop) and 002 (in second loop). However, it did not. The data extracted from the first loop is being filled in repeatedly to the "TableA" of dataset DS. Can anyone see the problem here? Please help to advise, thank you.
for (int i = 0; i < dset.Tables["TableB"].Rows.Count; i++)
drow = dset.Tables["TableB"].Rows[i];
string srNum = drow["col1"].ToString();
dadpmod.SelectCommand.CommandText = "select AData.*, " +
"data.*, car.* from (AData inner join data " +
"on AData.A = data.B ) inner join " +
"car on car.type = data.type " +
"where AData.SN = @sn
dadpmod.SelectCommand.Parameters.Add(new OleDbParameter("sn", srNum));