在做vb+sqlserver软件时的一些不明白的问题,希望得到您的解答谢谢!!!!!!!!!
主要是一些语句方面的
例如下面两条语句
sqlstmt="select student_id,student_name from students where class_id=" _
        +trim(str(tmpclassid))
SqlStmt = "SELECT Class_Id FROM Classes WHERE class_name='"+trim _(class_name)+"'"
大家看没条语句的条件部分,第一条class_id是integer,第二条的class_name是string ,为什么是数字类型的就可以写成"+trim(str(tmpclassid)),为什么它不象第二条中的那样需要变成这样'"+trim(str(tmpclassid)+"'?而第二条条件部分又为什么要那样写了?不明白啊,希望您尽快给我答复!

解决方案 »

  1.   

    Access里面:
    日期前后需要有“#”,
    字符串前后需要有“'”,
    数字前后没有。
      

  2.   

    如果不加'号的话,在SQL里会认为是一个量,但是数字型的就不会是变量,所以不要标.
      

  3.   

    你用inputbox将语句显示出来就看出来了
    strTemp="1"
    intTemp=1
    strSQL = "select * from aaa where id=" & intTemp
    inputbox 1,1,strsql
    显示出来的就是
    select * from aaa where id= 1strSQL = "select * from aaa where id=" & "'" & intTemp & "'"
    inputbox 1,1,strSQL
    显示出来的就是
    select * from aaa where id= '1'
      

  4.   

    写错了,第二个intTemp应该改为strTemp