|
-
Dec 22nd, 2006, 12:30 PM
#1
Thread Starter
New Member
[RESOLVED]SQL statement in VB and databinding for FlexGrid
How do I use SQL statement inside VB? What's the syntex for that? I am trying to do the samething as in Access with query and then put the output data table inside a MSFlexGrid. I am using VB6, Access 2002, and MSFlexGrid 6.0.
Am I able to do a databind with the output table from the query? If so, how?
thank you in advance.
Last edited by Raing; Dec 22nd, 2006 at 04:26 PM.
-
Dec 22nd, 2006, 12:36 PM
#2
Thread Starter
New Member
Re: SQL statement in VB and databinding for FlexGrid
DataGrid should work fine in this case too. It doesn't have to be FlexGrid. The databind should work the same for both I think.
-
Dec 22nd, 2006, 02:14 PM
#3
Thread Starter
New Member
Re: SQL statement in VB and databinding for FlexGrid
Data1.Database.Execute "select " & TableName & "." & CheckedColumns(1) & " from " & TableName & " where " & TableName & "." & CheckedColumns(1) & " = ""04TC0052"" "
when I run this, it gave me error message that can't excute select. Any ideas what is wrong with this?
-
Dec 22nd, 2006, 03:36 PM
#4
Hyperactive Member
Re: SQL statement in VB and databinding for FlexGrid
Welcome, Raing!
You start making a connection to your database. May be that's already taken care of?
Code:
"select " & TableName & "." & CheckedColumns(1) & " from " & TableName & " where " & TableName & "." & CheckedColumns(1) & " = ""04TC0052"" "
In the above code CheckedColumns(1) must be identical with the field in database with table named what TableName is. This looks to be better like: "'04TC0052'".
Last edited by Ember; Dec 22nd, 2006 at 05:46 PM.
-
Dec 22nd, 2006, 04:22 PM
#5
Thread Starter
New Member
Re: SQL statement in VB and databinding for FlexGrid
The problem is solved.
Code:
Public Sub SearchDB()
Dim str As String
str = "select " & TableName & "." & CheckedColumns(1) & " from " & TableName & " where " & TableName & "." & CheckedColumns(1) & " = ""04TC0052"" "
'Data1.Database.CreateQueryDef "test", str
'Data1.Database.Execute
'Data1.Recordset = str
Data1.RecordSource = str
Data1.Refresh
End Sub
I used Data1.Recordset = str rather than Data1.RecordSouce.
Thank you Ember.
Merry Christmas!!!
Raing
-
Dec 22nd, 2006, 04:52 PM
#6
Hyperactive Member
Re: [RESOLVED]SQL statement in VB and databinding for FlexGrid
Last edited by Ember; Dec 22nd, 2006 at 04:58 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|