Select problem with MS Accsses

Mladen

Member
Joined
Feb 6, 2003
Messages
17
I have Table1, inside I have 3 diferent fields and 1 field which type is boolean(yes/no). When I try to retrive the records that
are checked with
"Dim com As String = "SELECT field1,field2,field3,field4 FROM Table1 WHERE field4 = 1""
I dont get anything.
There is no errors,everything passes,everything works and my datagrid is still empty.
Help anyone????
 
Apparently your query does not find any records.



Open MS Access.

Try out with the MS Access Queries until you have created a query that actually produces results. Switch to the "SQL" View in Access and copy the string.
 
Non of this solves the problem.
Heikos sugestions works in Accsses , but when I pass the exact same string from VB .NET still my datagrid is empty.
Robbys sugestion doesnt help either.
Everything passes , and still nothing happens.
Thanks for trying to help.
Im still interested in solwing the problem.
 
Private Sub First_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim com As String = "SELECT field1,field2,field3,field4 FROM(Table1) WHERE (((Table1.field4)= True));
Dim ole As New OleDbDataAdapter(com, OleDbConnection1)
ole.Fill(Ds1, "Table1")

End Sub

The SELECT query was generated from MS Accsses ,I inserted it like it came from SQL View and still nothing happens.
I have selected, in properties window, the DataSource property and it is set to Table1.
 
Idea:
Select * from Table1.


Now have a look at the returnvalue for field4. Is iit 1, 0, -1 or TRUE or "True" or whatever.

Then edit the SQL.

It seems you have brackets in abundance .. you should reduce their number. Actually your SQL statement doesnt require ANY brackets "( )" at all.
 
The return value is a checkbox.
My problem is that I want to select only the checked items in the database .Simple ,but not efective.
 
Do you know if your DS1 and OleDbConnection1 are valid (correct)?

If you do this, will it fill your datagrid?

"Select * From Table1"
 
what is Ds1 a regular dataset or typed dataset? and are you sure Table1 in your dataset is what is bound to the datagrid? Wheres your binding code?
 
I solved the problem like this:
created a connection in server explorer.
drag-and-drop oledbconnection1 and oldataadapter1 on to the project.
changed the select command text "SELECT * from Table1 where field4 = true"
And it worked like I wanted to work.
But still it doesnt work if I want to do it programaticly.
If someone can still help me with that Ill be wery happy.
Ill work like this until someone shows me the way to do it.

Thanks to all of you who showed intrest to help stupid me with the smallest of problems with jast a few lines of code .
But what hapens when the projects start to get big?
 
Back
Top