奏国安新浪博客:插入数据库access中的表示

来源:百度文库 编辑:中科新闻网 时间:2024/04/30 08:01:15
SQLstr5 = "INSERT INTO data_register(patient_name,patient_id,mobilephone,patient_gender,password,doctor_id, doctor_name,flag) VALUES('"&patient_name&"','"&patient_id&"','"&mobilephone&"', '"&patient_gender&"','"&password&"','"&doctor_id&"','"&doctor_name&"','"&flag&"')"

其中doctor_id,patient_id,flag是数字形式的,其他的为字符形式的
这样编译后出错
不知得怎么表示才好?
"&cstr(flag)&"
的话应该就是把数据库中的数据类型也转成字符型的了
那样也得把数据库中的类型改阿〉?
如果不改可以吗?

数字形式就不用加 ' 了吧
试试看下面的写法:

SQLstr5 = "INSERT INTO data_register(patient_name,patient_id,mobilephone,patient_gender,password,doctor_id, doctor_name,flag) VALUES('"+patient_name+"',"+patient_id+",'"+mobilephone+"', '"+patient_gender+"','"+password+"',"+doctor_id+",'"+doctor_name+"',"+flag+")"

SQLstr5 = "INSERT INTO data_register(patient_name,patient_id,mobilephone,patient_gender,password,doctor_id, doctor_name,flag) VALUES('"&patient_name&"','"&patient_id&"','"&mobilephone&"', '"&patient_gender&"','"&password&"',"&cstr(doctor_id)&",'"&doctor_name&"',"&cstr(flag)&")"