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

DataGrid control

I want to display in a data grid control only the recordsets queried from a table and I want it to clear and display the new results when I do a new query.
The control is bound to the database's table ok, displays all the current data.
this is what I  got:
adodc's(in this case is called dcVideo) command is set to adcmdtext
Dim strSQL As String
 
  strSQL = "select * from films1 where "
  If strvalue = 1 Then
       If Option1.Value = True Then
     strSQL = strSQL & "year=2000"
      End If
      If Option2.Value = True Then
      strSQL = strSQL & "year>1989"
      End If
      If Option3.Value = True Then
      strSQL = strSQL & "year>1979 and year<1990"
      End If
      If Option4.Value = True Then
      strSQL = strSQL & "year<1979"
      End If
  ElseIf strvalue = 2 Then
      strSQL = strSQL & "oscar_award=A"
  ElseIf strvalue = 3 Then
      strSQL = strSQL & "categories=List1.Text"
  End If
  With dcVideo
      .RecordSource = strSQL
      .Refresh
  End With
for some reason it works fine when strvalue=1 but it doesn't work with the other two, everything goes fine until it gets to the refresh of dcvideo ("no value given for one or more parameters"), the string given to the recordsource is the right one.
Any idea please?(I'm going nuts)
0
txarli33
Asked:
txarli33
  • 2
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
Because Year is numeric and other fields are characters!

change to:

  ElseIf strvalue = 2 Then
      strSQL = strSQL & "oscar_award='A'"
  ElseIf strvalue = 3 Then
      strSQL = strSQL & "categories='" & List1.Text & "'"
  End If
0
 
txarli33Author Commented:
I think you are right, strvalue =2 works now but strvalue =3 still doesn't, how can I change a string to a numeric value?
0
 
txarli33Author Commented:
I love you,
it took me a bit to see the marks properly on the screen , that's why I sent that comment, but you were right.
Thanx, indeed
0
 
Éric MoreauSenior .Net ConsultantCommented:
why a B ?
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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