Anti-Rich
Well-known member
hi all,
i have the following code
for improved readability here is the query i run in SQLME
i dont understand why it does not return any rows on the database (and i know there are rows matching the query, since when i run the query in sql manager express (with the parameter replaced by a valid id), it works no problem. is it possible that the parameter i defined does not go into the subqueries?
i would greatly appreciate anyone's input
regards
adam
i have the following code
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ds [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet[/SIZE]
[SIZE=2]sql = [/SIZE][SIZE=2][COLOR=#800000]"SELECT 'Item'=n.Description, "[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]"'Times Picked'= "[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]"("[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]"select count(Qty) from tblWT where ID= '@ID"[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]")"[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]","[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]"'Volume Picked'="[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]"("[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]"select sum(Qty) from tblWT WHERE ID= '@ID'"[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]")"[/COLOR][/SIZE][SIZE=2] & _[/SIZE]
[SIZE=2][COLOR=#800000]"FROM tblWT w, tblNSN n WHERE n.NSN = '@ID' GROUP BY n.Description ORDER BY 'Times Picked' Asc"[/COLOR][/SIZE]
[SIZE=2]cmd = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand(sql, cnn)[/SIZE]
[SIZE=2]cmd.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#800000]"ID"[/COLOR][/SIZE][SIZE=2], txtID.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sDa [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlDataAdapter(cmd)[/SIZE]
[SIZE=2]sDa.Fill(ds)[/SIZE]
[SIZE=2]dgInfo.DataSource = ds[/SIZE]
for improved readability here is the query i run in SQLME
VB.NET:
[SIZE=2][COLOR=#0000ff]select [/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]'Item'[/COLOR][/SIZE][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][SIZE=2]n[/SIZE][SIZE=2][COLOR=#808080].[/COLOR][/SIZE][SIZE=2]Description[/SIZE][SIZE=2][COLOR=#808080],[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]'Times Picked'[/COLOR][/SIZE][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080]([/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]select [/COLOR][/SIZE][SIZE=2][COLOR=#ff00ff]count[/COLOR][/SIZE][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][SIZE=2]Qty[/SIZE][SIZE=2][COLOR=#808080]) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]from[/COLOR][/SIZE][SIZE=2] tblWT [/SIZE][SIZE=2][COLOR=#0000ff]where[/COLOR][/SIZE][SIZE=2] ID[/SIZE][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]'000013388'[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080],[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]'Volume Picked'[/COLOR][/SIZE][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080]([/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]select [/COLOR][/SIZE][SIZE=2][COLOR=#ff00ff]sum[/COLOR][/SIZE][SIZE=2][COLOR=#808080]([/COLOR][/SIZE][SIZE=2]Qty[/SIZE][SIZE=2][COLOR=#808080]) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]from[/COLOR][/SIZE][SIZE=2] tblWT [/SIZE][SIZE=2][COLOR=#0000ff]WHERE[/COLOR][/SIZE][SIZE=2] ID [/SIZE][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]'000013388'[/COLOR][/SIZE]
[SIZE=2][COLOR=#808080])[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]from[/COLOR][/SIZE][SIZE=2] tblWT w[/SIZE][SIZE=2][COLOR=#808080],[/COLOR][/SIZE][SIZE=2] tblID n [/SIZE][SIZE=2][COLOR=#0000ff]WHERE[/COLOR][/SIZE][SIZE=2] n[/SIZE][SIZE=2][COLOR=#808080].[/COLOR][/SIZE][SIZE=2]ID[/SIZE][SIZE=2][COLOR=#808080]=[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]'000013388' [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]group [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]by[/COLOR][/SIZE][SIZE=2] n[/SIZE][SIZE=2][COLOR=#808080].[/COLOR][/SIZE][SIZE=2]Description [/SIZE][SIZE=2][COLOR=#0000ff]ORDER[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]BY [/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]'Times Picked' [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Asc[/COLOR][/SIZE]
i would greatly appreciate anyone's input
regards
adam
Last edited: