from前面多了一个",",另外如果prof字段是字符串型的,则必须加引号

解决方案 »

  1.   

    谢谢!from前面多了一个",",那是我打错了!不好意思!
    另外,prof字段是文本型的,我加了单引号还是报同样的错误!!!???
      

  2.   

    真是不好意思,那都是我打错了!正确的应该是:
    select person.name,person.prof,person.seryear," _
                             & "monthsalary.month,monthsalary.salary,monthsalary.bonus, "_                   & "monthsalary.deduct,monthsalary.fact" _
    & " from person,monthsalary where person.prof = " & Me.Combo2.Text
      

  3.   

    "select person.name,person.prof from person where person.prof = '" _ 
    & Combo1.Text & "'"  
      

  4.   

    再回答一次吧,从两个表中选取数据怎么能不指定这两个表的关系呢
    from 后面应该是 "from person inner join monthsalary on person.personid = monthsalary.personid where person.prof = '" & Me.Combo2.Text & "'"
    personid是我假定的连接字段
      

  5.   

    "select person.name,person.prof,person.seryear, _
    & monthsalary.month,monthsalary.salary,monthsalary.bonus, _
    & monthsalary.deduct,monthsalary.fact _
    & from person,monthsalary where person.prof = '" & Me.Combo2.Text & "'"
      

  6.   

    to huanggx(大侠):
    对了!但是person.prof和Combo1.Text都是字符型的,为什么在Combo1.Text上要加一个''?
      

  7.   

    对不起。应该是:
    "select person.name,person.prof,person.seryear,"  _
    & "monthsalary.month,monthsalary.salary,monthsalary.bonus," _
    & "monthsalary.deduct,monthsalary.fact" _
    & "from person,monthsalary where person.prof = '" & Me.Combo2.Text & "'" 
      

  8.   

    因为combo2.text在这里只是字符串的内容,不包含''。而数据库需要''。
      

  9.   

    我还是不怎么明白!也就是说,为什么要person.prof = '高级',而不能person.prof = 高级
      

  10.   

    没错。
    我给你比个例子:
    假设你的combo2.text的内容是abcd
    那么,如果你写成这样:"select fld1 from table1 where fld2=abcd"
    和写成"select fld1 from table1 where fld2=" & combo2.text有什么区别?
    但是,"select fld1 from table1 where fld2=abcd"是不正确的。应该是:
    "select fld1 from table1 where fld2='abcd'"
    明白了?
      

  11.   

    还是不明白!两边都是字符型呀!按照你的说法,就是要abcd = 'abcd'罗!
      

  12.   

    回复人: luoxiang2000(腾空) (2001-8-8 0:20:01)  得0分 
    还是不明白!两边都是字符型呀!按照你的说法,就是要abcd = 'abcd'罗!  等号前面的是字段名,后面是值