Mladen Posted March 3, 2003 Posted March 3, 2003 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 don't get anything. There is no errors,everything passes,everything works and my datagrid is still empty. Help anyone???? Quote
Heiko Posted March 3, 2003 Posted March 3, 2003 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. Quote .nerd
Moderators Robby Posted March 3, 2003 Moderators Posted March 3, 2003 You can do this with a boolean... "......WHERE field4 = " & True Quote Visit...Bassic Software
Mladen Posted March 4, 2003 Author Posted March 4, 2003 Non of this solves the problem. Heiko's sugestions works in Accsses , but when I pass the exact same string from VB .NET still my datagrid is empty. Robby's sugestion doesn't help either. Everything passes , and still nothing happens. Thanks for trying to help. I'm still interested in solwing the problem. Quote
Leaders quwiltw Posted March 4, 2003 Leaders Posted March 4, 2003 can you post the relevant code for populating your datagrid? Quote --tim
Mladen Posted March 4, 2003 Author Posted March 4, 2003 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. Quote
Heiko Posted March 4, 2003 Posted March 4, 2003 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 doesn't require ANY brackets "( )" at all. Quote .nerd
Mladen Posted March 4, 2003 Author Posted March 4, 2003 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. Quote
Moderators Robby Posted March 4, 2003 Moderators Posted March 4, 2003 Do you know if your DS1 and OleDbConnection1 are valid (correct)? If you do this, will it fill your datagrid? "Select * From Table1" Quote Visit...Bassic Software
Leaders quwiltw Posted March 4, 2003 Leaders Posted March 4, 2003 what is Ds1 a regular dataset or typed dataset? and are you sure Table1 in your dataset is what is bound to the datagrid? Where's your binding code? Quote --tim
Mladen Posted March 4, 2003 Author Posted March 4, 2003 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 doesn't work if I want to do it programaticly. If someone can still help me with that I'll be wery happy. I'll 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? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.