ID   名字    数学   语文
1    啊啊    67     
2    我      56
3    个      65
4    小王    56
5    的      45语文为新建的字段
我要把小王的语文成绩写进去
怎么写啊

解决方案 »

  1.   

    假定表名为TABEL,小王语文成绩为"80",可用下面的SQL语句:update TABEL set 语文=80 where 名字='小王'
      

  2.   

    用ADO也行,“select * from tabel where 名字=小王”
          rs.Fields("语文")=80
                rs.update
      

  3.   

    简单实例,替换成你自己的数据库和表名即可Sub UpdateX()
    Dim dbsNorthwind As Database
    Dim rstEmployees As Recordset
    Dim strOldFirst As String
    Dim strOldLast As String
    Dim strMessage As String Set dbsNorthwind = OpenDatabase("Northwind.mdb")
    Set rstEmployees = _
    dbsNorthwind.OpenRecordset("select * from Employees where 名字='小王'") With rstEmployees
    .Edit
    !语文 = "80"
                      
                      ’提示是否保存 
    If MsgBox(strMessage, vbYesNo) = vbYes Then
    .Update
    Else
    .CancelUpdate
    End If           .Close
    End With dbsNorthwind.CloseEnd Sub
      

  4.   

    dim cn as adodb.connection
      dim rs as adodb.recordset
      dim db as string
      db="..."
      dim sql as string
      sql="select * from ... where 名字='小王'"
      cn.connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &db
      cn.open
      rs.open sql,cn
      rs.recordset.movefirst
      rs.recordset.edit
      rs.recordset.fields("语文").value=...
      rs.recordset.update
      试试看,行不
      

  5.   

    Private Sub Command1_Click()
    Dim cn As ADODB.Connection
    Set cn = New ADODB.Connection  Dim sql As String
      sql = "update TABEL set 语文=80 where 名字='小王'"
      cn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db
      cn.open
      cn.Execute sql
      
    End Sub
      

  6.   

    重新打开记录集,用 select * ...,或者 select ID,名字,数学,语文...。总之,将新字段包含进来。
      

  7.   

    local_sql = "Select * FROM table  WHERE 名字 = 小王"
    my_recordset.Open local_sql, connect, adOpenDynamic, adLockOptimistic, -1
    my_recordset.Fields("语文").Value = Text1.Text
    my_recordset.Update
    执行的时候出现实施错误'-2147217904 (8004010e10)':
     NO value give for one or more required paraters
    用的是ADO空件
    但是这样的话
    local_sql = "Select * FROM table "
    my_recordset.Open local_sql, connect, adOpenDynamic, adLockOptimistic, -1
    my_recordset.Fields("语文").Value = Text1.Text
    my_recordset.Update
    能够运行,不报错,
    问题是不是出在  
    WHERE 名字 = 小王
      

  8.   

    小王必须用半角单引号括起来,应该这样写:
    local_sql = "Select * FROM table  WHERE 名字 = '小王'"