如何在vb里用sql语句的update语句修给sql server数据库??急!!
Private rs As New ADODB.Recordset
Private cData As New CDataBase
打开数据库
sql = "update worktime set work_time with '" + "5:00"+ "'"+ "where Userid='" + txtid.Text + "'"
rs.Open sql, cData.db
老是出错,,给高手给出答案把,,,,,
问题点数:100、回复次数:10Top
1 楼txlicenhe(马可)回复于 2003-10-03 09:36:52 得分 10
dim cn as new ADODB.Connection
cn.open ...
sql = "update worktime set work_time = '" + "5:00" + "'" + " where Userid = '" + txtid.Text + "'"
cn.execute sql
Top
2 楼hwmys(★H-Soft★)回复于 2003-10-03 09:39:43 得分 10
应该如此:
sql = "update worktime set work_time = " & "5:00" & " where Userid = '" & txtid.Text & "'"Top
3 楼zlpanzy(.net_jackaroo)回复于 2003-10-03 09:53:07 得分 10
sql = " update worktime set work_time = '" + "5:00" + "' " _
& " where Userid = '" + txtid.Text + "'"
rs.execute sql
提醒在你有多条修改语句同时对库修改时,建议用事务来控制
Top
4 楼zlpanzy(.net_jackaroo)回复于 2003-10-03 09:57:10 得分 10
补充:rs.execute 中需定义rs为连接而非记录
dim rs as ADODB.Connection
set rs=new ADODB.ConnectionTop
5 楼dengyiwolf(七星偃月刀)回复于 2003-10-03 12:59:53 得分 10
up一下Top
6 楼lsm0959(小姓李)回复于 2003-10-03 19:48:19 得分 10
用connection.execute(update语句)来执行,
如果是多用户环境建议用事务来完成Top
7 楼wea1978(川)回复于 2003-10-03 19:58:16 得分 10
这样就可以:
sql = "update worktime set work_time = '5:00' where Userid = '" & Trim(txtid.Text) & "'"
如果是你自己确定的参数,就不用去加"&"还是"+"了.Top
8 楼xinshou1979330(Success.java)回复于 2003-10-03 21:35:01 得分 10
同意楼上说的
用 & 它
+ 是 JAVA中的Top
9 楼yoki(小马哥--鬓微霜,又何妨)回复于 2003-10-04 00:30:23 得分 10
dim cn as new adodb.connection
cn.execute "update worktime set work_time with '" + "5:00"+ "'"+ "where Userid='" + txtid.Text + "'"Top
10 楼Gelim(Gelim)回复于 2003-10-04 11:38:25 得分 10
dim cn as new adodb.connection
cn.execute "update worktime set work_time with '" & "5:00"+ "'" & "where Userid='" & txtid.Text & "'"
Top




