请问在VB里怎样修改SQL SERVER数据库中的数据??急!!!请各位大侠帮帮忙!!!!!!!!!

解决方案 »

  1.   

    Public CN As ADODB.Connection
    Public AtRs As ADODB.RecordsetPublic Function OpenCon()
    StrCn = "driver={SQL server};server=mdx;uid=sa;pwd=;database=dagl"
    Set CN = New ADODB.Connection
    CN.Open StrCnSet AtRs = New ADODB.Recordset
    Set AtRs.ActiveConnection = CN
    AtRs.CursorType = adOpenKeyset
    AtRs.LockType = adLockBatchOptimisticEnd FunctionPrivate Sub cmdEdit_Click()
      OpenCon         
       EditQuerySQL = "select * from exp_guding Where ny = " & "'" & Format(Trim(MaskRq.Text) & "-01", "yyyy-mm-dd") & "'"
       
     If AtRs.State = adStateOpen Then AtRs.Close
     AtRs.Open EditQuerySQL, StrCn, , , adCmdText   AtRs!Gz_jb_gp = CDbl(Trim(TxtGz_jb_gp.Text))   '修改数据库中的数据
       AtRs.UpdateBatch
       MsgBox "年月为:" & Trim(MaskRq.Text) & " 的记录修改成功。", vbInformation, Me.Caption + "-修改记录提示"
    End Sub
      

  2.   

    不明白, 不过首先你要连接上数据库才能进行添加。命令,修改 直接用rs.UPDATE
    dim rs as adodb.recordset
    dim con as adodb.connectionSet con = New ADODB.Connection
    Set rs = New ADODB.Recordsetcon.ConnectionString = "Provider=SQLOLEDB.1;Password=123;Persist Security Info=True;User ID=sa;Initial Catalog=mrmt;Data Source=N091"
    con.CursorLocation = adUseClient
    con.Open
    '上面是连接数据库rs.Open "select * from blgl where danhao='" & Label9.Caption & "'", con, adOpenKeyset, adLockOptimistic
    rs!zl_jine = Text1.Text
    rs.Update
      

  3.   

    改SQL的什么东西,比如?又不说清楚:
    比如sql中间表a
    id name 
    1  snow
    2  sue
    修改snow的名字为jackOption Explicit
    Public conn As New ADODB.Connection
    '---中间的连接代码省略Private Sub Form_Load()
     conn.Execute "Update a set name='jack' where name='snow'"
    End Sub
      

  4.   

    conn.Execute "Update table set alary=2000 where  name='jack'"