Hi -
For my VB.NET app, I have a SQL2K database that I use to create a dataset
with multiple data tables. I've created a dataview (dvReportsTo) of one of
the tables, SCPMaster, and I've bound a combobox control to that dataview.
I'm trying to filter the dataview based on values in a second table
(ReportsTo) in the same dataset, and it's not working.
If it's possible to do this, please help me figure out what I've done wrong
and how to implement this correctly. If I'm trying to do something that is
not supported, I'd appreciate any suggestions of a workaround.
Here's the filter I'm trying to implement:
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'"
strFilter &= " AND SCPMasterID NOT IN"
strFilter &= " (SELECT ReportsToStaffID FROM ReportsTo"
strFilter &= " WHERE ReportsToBossID = '" & uidSelectedPerson.ToString &
"')"
frmMain.dvReportsTo.RowFilter = strFilter
Here's the DataException that I'm getting:
System.Data.SyntaxErrorException: Syntax error: Missing operand after
'ReportsToStaffID' operator.
at System.Data.ExpressionParser.Parse()
at System.Data.DataExpression..ctor(String expression, DataTable table,
Type type)
at System.Data.DataExpression..ctor(String expression, DataTable table)
at System.Data.DataFilter..ctor(String expression, DataTable table)
at System.Data.DataView.set_RowFilter(String value)
at StarContactPro_02_DT.modContact.SetReportsToFilter () in d:\Data\Visual
Studio Projects\StarContactPro-02-DT\modContact.vb:line 107"
Thanks for your help.
- Jeff 7 14070
The subquery is the problem. You're going to have to do a dataTable.Select
and loop through the results, building a comma separated list. Then use
that list with Not In. For the complete expression syntax, this may be of
help to you in the future http://msdn.microsoft.com/library/de...ssionTopic.asp
--
W.G. Ryan, eMVP http://forums.devbuzz.com/ http://www.knowdotnet.com/williamryan.html http://www.msmvps.com/WilliamRyan/ http://www.devbuzz.com/content/zinc_...center_pg1.asp
"Jeff" <je*********@eNetPortals.com> wrote in message
news:CO***************@newsread3.news.atl.earthlin k.net... Hi -
For my VB.NET app, I have a SQL2K database that I use to create a dataset with multiple data tables. I've created a dataview (dvReportsTo) of one
of the tables, SCPMaster, and I've bound a combobox control to that dataview. I'm trying to filter the dataview based on values in a second table (ReportsTo) in the same dataset, and it's not working.
If it's possible to do this, please help me figure out what I've done
wrong and how to implement this correctly. If I'm trying to do something that
is not supported, I'd appreciate any suggestions of a workaround.
Here's the filter I'm trying to implement:
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'" strFilter &= " AND SCPMasterID NOT IN" strFilter &= " (SELECT ReportsToStaffID FROM ReportsTo" strFilter &= " WHERE ReportsToBossID = '" & uidSelectedPerson.ToString & "')"
frmMain.dvReportsTo.RowFilter = strFilter
Here's the DataException that I'm getting:
System.Data.SyntaxErrorException: Syntax error: Missing operand after 'ReportsToStaffID' operator. at System.Data.ExpressionParser.Parse() at System.Data.DataExpression..ctor(String expression, DataTable table, Type type) at System.Data.DataExpression..ctor(String expression, DataTable table) at System.Data.DataFilter..ctor(String expression, DataTable table) at System.Data.DataView.set_RowFilter(String value) at StarContactPro_02_DT.modContact.SetReportsToFilter () in
d:\Data\Visual Studio Projects\StarContactPro-02-DT\modContact.vb:line 107"
Thanks for your help.
- Jeff
"Jeff" <je*********@eNetPortals.com> schrieb Here's the filter I'm trying to implement:
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'" strFilter &= " AND SCPMasterID NOT IN" strFilter &= " (SELECT ReportsToStaffID FROM ReportsTo" strFilter &= " WHERE ReportsToBossID = '" & uidSelectedPerson.ToString & "')"
frmMain.dvReportsTo.RowFilter = strFilter
Here's the DataException that I'm getting:
System.Data.SyntaxErrorException: Syntax error: Missing operand after 'ReportsToStaffID' operator. at System.Data.ExpressionParser.Parse() at System.Data.DataExpression..ctor(String expression, DataTable table, Type type) at System.Data.DataExpression..ctor(String expression, DataTable table) at System.Data.DataFilter..ctor(String expression, DataTable table) at System.Data.DataView.set_RowFilter(String value) at StarContactPro_02_DT.modContact.SetReportsToFilter () in d:\Data\Visual Studio Projects\StarContactPro-02-DT\modContact.vb:line 107"
The Dataview is not a database. You can not execute SQL statements on the
Dataview. The valid syntax for the Rowfilter is described here: http://msdn.microsoft.com/library/en...ssionTopic.asp
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Thanks for the instant(!) response, William -
I've tried your suggestion, and there seems to be a problem with the values
in the comma-separated NOT IN list being GUIDs. (I went through the article
you referenced, and I wasn't able to find the correct syntax for this.)
What should I change??
Here's my relevant code:
strStaff = "("
strFilter = "ReportsToBossID = '" & uidSelectedPerson.ToString & "'"
drStaff = frmMain.dsSCP.Tables("ReportsTo").Select(strFilter )
intRows = drStaff.GetUpperBound(0)
For intRow = 0 To intRows
If blnFirstItem Then
blnFirstItem = False
Else
strStaff &= ","
End If
strStaff &= "'" & drStaff(intRow)(0).ToString & "'"
Next
strStaff &= ")"
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'"
If intRows > 0 Then strFilter &= " AND SCPMasterID NOT IN " &
strStaff
frmMain.dvReportsTo.RowFilter = strFilter
Thanks for your help.
- Jeff
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:eB*************@tk2msftngp13.phx.gbl... The subquery is the problem. You're going to have to do a
dataTable.Select and loop through the results, building a comma separated list. Then use that list with Not In. For the complete expression syntax, this may be of help to you in the future http://msdn.microsoft.com/library/de...ssionTopic.asp --
W.G. Ryan, eMVP
http://forums.devbuzz.com/ http://www.knowdotnet.com/williamryan.html http://www.msmvps.com/WilliamRyan/ http://www.devbuzz.com/content/zinc_...center_pg1.asp "Jeff" <je*********@eNetPortals.com> wrote in message news:CO***************@newsread3.news.atl.earthlin k.net... Hi -
For my VB.NET app, I have a SQL2K database that I use to create a
dataset with multiple data tables. I've created a dataview (dvReportsTo) of one of the tables, SCPMaster, and I've bound a combobox control to that
dataview. I'm trying to filter the dataview based on values in a second table (ReportsTo) in the same dataset, and it's not working.
If it's possible to do this, please help me figure out what I've done wrong and how to implement this correctly. If I'm trying to do something that is not supported, I'd appreciate any suggestions of a workaround.
Here's the filter I'm trying to implement:
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'" strFilter &= " AND SCPMasterID NOT IN" strFilter &= " (SELECT ReportsToStaffID FROM ReportsTo" strFilter &= " WHERE ReportsToBossID = '" & uidSelectedPerson.ToString & "')"
frmMain.dvReportsTo.RowFilter = strFilter
Here's the DataException that I'm getting:
System.Data.SyntaxErrorException: Syntax error: Missing operand after 'ReportsToStaffID' operator. at System.Data.ExpressionParser.Parse() at System.Data.DataExpression..ctor(String expression, DataTable
table, Type type) at System.Data.DataExpression..ctor(String expression, DataTable
table) at System.Data.DataFilter..ctor(String expression, DataTable table) at System.Data.DataView.set_RowFilter(String value) at StarContactPro_02_DT.modContact.SetReportsToFilter () in d:\Data\Visual Studio Projects\StarContactPro-02-DT\modContact.vb:line 107"
Thanks for your help.
- Jeff
If you would ,set a breakpoint right before you set the rowfilter and let me
see what the exact command you're setting is. it's hard to tell from here
and I don't have your values so i can't easily tell.
--
W.G. Ryan MVP Windows - Embedded http://forums.devbuzz.com http://www.knowdotnet.com/dataaccess.html http://www.msmvps.com/williamryan/
"Jeff" <je*********@eNetPortals.com> wrote in message
news:Yz*****************@newsread3.news.atl.earthl ink.net... Thanks for the instant(!) response, William -
I've tried your suggestion, and there seems to be a problem with the
values in the comma-separated NOT IN list being GUIDs. (I went through the
article you referenced, and I wasn't able to find the correct syntax for this.) What should I change??
Here's my relevant code:
strStaff = "(" strFilter = "ReportsToBossID = '" & uidSelectedPerson.ToString &
"'" drStaff = frmMain.dsSCP.Tables("ReportsTo").Select(strFilter )
intRows = drStaff.GetUpperBound(0) For intRow = 0 To intRows If blnFirstItem Then blnFirstItem = False Else strStaff &= "," End If strStaff &= "'" & drStaff(intRow)(0).ToString & "'" Next strStaff &= ")"
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'" If intRows > 0 Then strFilter &= " AND SCPMasterID NOT IN " & strStaff
frmMain.dvReportsTo.RowFilter = strFilter
Thanks for your help.
- Jeff
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message news:eB*************@tk2msftngp13.phx.gbl... The subquery is the problem. You're going to have to do a dataTable.Select and loop through the results, building a comma separated list. Then use that list with Not In. For the complete expression syntax, this may be
of help to you in the future
http://msdn.microsoft.com/library/de...ssionTopic.asp --
W.G. Ryan, eMVP
http://forums.devbuzz.com/ http://www.knowdotnet.com/williamryan.html http://www.msmvps.com/WilliamRyan/ http://www.devbuzz.com/content/zinc_...center_pg1.asp "Jeff" <je*********@eNetPortals.com> wrote in message news:CO***************@newsread3.news.atl.earthlin k.net... Hi -
For my VB.NET app, I have a SQL2K database that I use to create a dataset with multiple data tables. I've created a dataview (dvReportsTo) of
one of the tables, SCPMaster, and I've bound a combobox control to that dataview. I'm trying to filter the dataview based on values in a second table (ReportsTo) in the same dataset, and it's not working.
If it's possible to do this, please help me figure out what I've done wrong and how to implement this correctly. If I'm trying to do something
that is not supported, I'd appreciate any suggestions of a workaround.
Here's the filter I'm trying to implement:
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'" strFilter &= " AND SCPMasterID NOT IN" strFilter &= " (SELECT ReportsToStaffID FROM ReportsTo" strFilter &= " WHERE ReportsToBossID = '" & uidSelectedPerson.ToString
& "')"
frmMain.dvReportsTo.RowFilter = strFilter
Here's the DataException that I'm getting:
System.Data.SyntaxErrorException: Syntax error: Missing operand after 'ReportsToStaffID' operator. at System.Data.ExpressionParser.Parse() at System.Data.DataExpression..ctor(String expression, DataTable
table, Type type) at System.Data.DataExpression..ctor(String expression, DataTable table) at System.Data.DataFilter..ctor(String expression, DataTable table) at System.Data.DataView.set_RowFilter(String value) at StarContactPro_02_DT.modContact.SetReportsToFilter () in
d:\Data\Visual Studio Projects\StarContactPro-02-DT\modContact.vb:line 107"
Thanks for your help.
- Jeff
Sure. Here's the value of strFilter:
"SCPMasterID <> '23865682-20c1-11c4-8000-8ea6b5cb2452' AND SCPMasterID NOT
IN
('3ac54427-20c1-11c4-8000-8ea6b5cb2452','3ac54429-20c1-11c4-8000-8ea6b5cb245
2','3ac5442b-20c1-11c4-8000-8ea6b5cb2452','3b5dda80-20c1-11c4-8000-8ea6b5cb2
452','3b5dda82-20c1-11c4-8000-8ea6b5cb2452')"
- Jeff
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:ut**************@tk2msftngp13.phx.gbl... If you would ,set a breakpoint right before you set the rowfilter and let
me see what the exact command you're setting is. it's hard to tell from
here and I don't have your values so i can't easily tell.
-- W.G. Ryan MVP Windows - Embedded
http://forums.devbuzz.com http://www.knowdotnet.com/dataaccess.html http://www.msmvps.com/williamryan/ "Jeff" <je*********@eNetPortals.com> wrote in message news:Yz*****************@newsread3.news.atl.earthl ink.net... Thanks for the instant(!) response, William -
I've tried your suggestion, and there seems to be a problem with the values in the comma-separated NOT IN list being GUIDs. (I went through the article you referenced, and I wasn't able to find the correct syntax for this.) What should I change??
Here's my relevant code:
strStaff = "(" strFilter = "ReportsToBossID = '" & uidSelectedPerson.ToString & "'" drStaff = frmMain.dsSCP.Tables("ReportsTo").Select(strFilter )
intRows = drStaff.GetUpperBound(0) For intRow = 0 To intRows If blnFirstItem Then blnFirstItem = False Else strStaff &= "," End If strStaff &= "'" & drStaff(intRow)(0).ToString & "'" Next strStaff &= ")"
strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString &
"'" If intRows > 0 Then strFilter &= " AND SCPMasterID NOT IN " & strStaff
frmMain.dvReportsTo.RowFilter = strFilter
Thanks for your help.
- Jeff
"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message news:eB*************@tk2msftngp13.phx.gbl... The subquery is the problem. You're going to have to do a dataTable.Select and loop through the results, building a comma separated list. Then
use that list with Not In. For the complete expression syntax, this may
be of help to you in the future http://msdn.microsoft.com/library/de...ssionTopic.asp --
W.G. Ryan, eMVP
http://forums.devbuzz.com/ http://www.knowdotnet.com/williamryan.html http://www.msmvps.com/WilliamRyan/ http://www.devbuzz.com/content/zinc_...center_pg1.asp "Jeff" <je*********@eNetPortals.com> wrote in message news:CO***************@newsread3.news.atl.earthlin k.net... > Hi - > > For my VB.NET app, I have a SQL2K database that I use to create a
dataset > with multiple data tables. I've created a dataview (dvReportsTo) of one of > the tables, SCPMaster, and I've bound a combobox control to that dataview. > I'm trying to filter the dataview based on values in a second table > (ReportsTo) in the same dataset, and it's not working. > > If it's possible to do this, please help me figure out what I've
done wrong > and how to implement this correctly. If I'm trying to do something that is > not supported, I'd appreciate any suggestions of a workaround. > > Here's the filter I'm trying to implement: > > strFilter = "SCPMasterID <> '" & uidSelectedPerson.ToString & "'" > strFilter &= " AND SCPMasterID NOT IN" > strFilter &= " (SELECT ReportsToStaffID FROM ReportsTo" > strFilter &= " WHERE ReportsToBossID = '" &
uidSelectedPerson.ToString & > "')" > > frmMain.dvReportsTo.RowFilter = strFilter > > Here's the DataException that I'm getting: > > System.Data.SyntaxErrorException: Syntax error: Missing operand
after > 'ReportsToStaffID' operator. > at System.Data.ExpressionParser.Parse() > at System.Data.DataExpression..ctor(String expression, DataTable table, > Type type) > at System.Data.DataExpression..ctor(String expression, DataTable table) > at System.Data.DataFilter..ctor(String expression, DataTable
table) > at System.Data.DataView.set_RowFilter(String value) > at StarContactPro_02_DT.modContact.SetReportsToFilter () in d:\Data\Visual > Studio Projects\StarContactPro-02-DT\modContact.vb:line 107" > > > Thanks for your help. > > - Jeff > >
Hi Jeff,
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to filter records that are not
in the Guid list. If there is any misunderstanding, please feel free to let
me know.
Based on my research, the Guid values in the list are strings that cannot
be converted implicitly to Guid. We have to use Convert function to change
it to Guid. Here is an example:
"SCPMasterID <> '23865682-20c1-11c4-8000-8ea6b5cb2452' AND SCPMasterID NOT
IN
(Convert('3ac54427-20c1-11c4-8000-8ea6b5cb2452', 'System.Guid'),
Convert('3ac54429-20c1-11c4-8000-8ea6b5cb2452', 'System.Guid'))"
HTH. If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Thanks, Guys -
I've been able to get this to work using William's and Kevin's
recommendations.
- Jeff
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:V1*************@cpmsftngxa10.phx.gbl... Hi Jeff,
First of all, I would like to confirm my understanding of your issue. From your description, I understand that you need to filter records that are
not in the Guid list. If there is any misunderstanding, please feel free to
let me know.
Based on my research, the Guid values in the list are strings that cannot be converted implicitly to Guid. We have to use Convert function to change it to Guid. Here is an example:
"SCPMasterID <> '23865682-20c1-11c4-8000-8ea6b5cb2452' AND SCPMasterID NOT IN (Convert('3ac54427-20c1-11c4-8000-8ea6b5cb2452', 'System.Guid'), Convert('3ac54429-20c1-11c4-8000-8ea6b5cb2452', 'System.Guid'))"
HTH. If anything is unclear, please feel free to reply to the post.
Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: duikboot |
last post by:
Hi all,
I'm trying to export a view tables from a Oracle database to a Mysql
database. I create insert statements (they look alright), but it all goes
wrong when I try to execute them in Mysql,...
|
by: LilleSkutt |
last post by:
I am trying to create and instantiate a class into a created domain, so that I can unload the domain and replace the class (assembly .dll) while the main application is running, but I can't get it to...
|
by: TrvlOrm |
last post by:
OK. After much playing around, I managed to get my frame page this
far.. see code below.
BUT...there are still errors with it, and what I would like to have
happened is this:
1) On the Left...
|
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application...
|
by: Chua Wen Ching |
last post by:
Hi there,
I have some problems when reading XML file.
1. First this, is what i did, cause i can't seem to read "sub elements or
tags" values, so i place those values into attributes like this....
|
by: steroche |
last post by:
I would REALLY appreciate help please please please! Im sure it is
probably blindingly obvious to most of you but I am totally in the dark
here!I am lost - i thought i had finally figured out this...
|
by: Tim_Mac |
last post by:
hi,
i'm new to .net 2.0, and am just starting to get to grips with the
gridview.
my page has autoEventWireUp set to true, which i gather is supposed to
figure out which handlers to invoke when...
|
by: Richard |
last post by:
Help please.
I am trying to autofill a form text field from a select-box lookup.
I have no problem doing this if the select-box is part of the form
but because there are 5 possible select boxes...
|
by: uno7031 |
last post by:
Help Please!!! Adding 5 Days to another Date in an access query
Good Morning,
Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |