• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

filling datagridview not working

VB.NET 2003

Dim sDB As String = "C:\Program Files\crst\Beta.mdb"
                Dim sConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & sDB
                Dim ds As New DataSet()
                Dim da As New OleDbDataAdapter("SELECT * FROM tblMainData WHERE fldSpin = 'WG' OR 'WV' OR 'DV' OR 'DG'", sConn)
                da.Fill(ds, "dt")
                DataGridView1.DataSource = ds.Tables("dt")

This select query is not picking up the "where" caluse...it still displays all the data ?

Thanks
fordraiders

0
Fordraiders
Asked:
Fordraiders
1 Solution
 
rajapandian_81Commented:
Try below query

SELECT * FROM tblMainData WHERE fldSpin in( 'WG','WV','DV','DG')
0
 
x77Commented:
Try

   Dim da As New OleDbDataAdapter("SELECT * FROM tblMainData WHERE fldSpin in ('WG' , 'WV' , 'DV' , 'DG')", sConn)
0
 
FordraidersAuthor Commented:
sorry not working ?
SELECT * FROM tblMainData WHERE fldSpin in( 'WG','WV','DV','DG')
Dim da As New OleDbDataAdapter("SELECT * FROM tblMainData WHERE tblMainData.fldSpin In('WG' OR 'WV' OR 'DV' OR 'DG')", sConn)
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
FordraidersAuthor Commented:
x77 worked..
Dim da As New OleDbDataAdapter("SELECT * FROM tblMainData WHERE fldSpin in ('WG' , 'WV' , 'DV' , 'DG')", sConn)


ok...whats with the "OR"   ?  THEN USING A COMMA instead ?




0
 
Alfred A.Commented:
0
 
x77Commented:
The clause field in (value1,value2,...) is equivalent to (field =value1 or field=value2 or....)
It is an abreviated solution. You can´not write  Field=Value1 or Value2.....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now