字符型:sql="select * from tablename where id='" & tyid & "'" '用单引号括全了(也就是前后都不能差)整型:sql="select * from tablename where id= " & tyid '这样就可以
id 是什么类型?长整型吧,如果TYID是整型,sql="select * from tablename where id=" & tyid 如果TYID是字符型,sql="select * from tablename where id=" & CDBL(tyid )
字符型:直接 sql="select * from tablename where id="&tyid ,&来连接两个字符串整型:sql="select * from tablename where id="&cstr(tyid) , cstr()将非字符型转化为字符型,然后&符号进行字符串连接