说得不明白,清楚些,删除表中的数据?删除数据表/?在VB中连接SQL server后,执行删除操作不就行了

解决方案 »

  1.   

    删除数据还是删除数据库对象?打开一个到SQL的连接,    Dim cnn As Connection
        Set cnn = New Connection
        
        cnn.Open "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=MyDB;Data Source=."
        
    删除表中的数据
        cnn.Execute "delete tablename where ..."
    删除表
        cnn.Execute "drop table tablename"
      

  2.   

    我想删除SQL数据库中一个表中的数据
      

  3.   

    cnn.Execute "delete tablename where ..."
      

  4.   

    cnn.Execute "delete tablename "
    这样删除整张表
      

  5.   

    数据表增删改代码
    你试试这样做,引用ado 
        Dim Con As ADODB.Connection
        Dim rs As ADODB.Recordset
        Set Con = New ADODB.Connection
        strCon = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=MyDB;Data Source=."
        Con.Open strCon
        Set rs = New ADODB.Recordset
        '添加记录
        strsql="select * from table"
        rs.Open strsql, Con, adOpenKeyset, adLockOptimistic      
        rs.addnew
           rs!字段1=text1.text
           rs!字段2=text2.text
           ........
        rs.update
        rs.close
        set rs=nothing
        '修改记录
        strsql="select * from table where id=1"
        rs.Open strsql, Con, adOpenKeyset, adLockOptimistic      
           rs!字段1=text1.text
           rs!字段2=text2.text
           ........
        rs.update
        rs.close
        set rs=nothing
            
        '删除记录
        strsql="delete from table where id=1"
        rs.Open strsql, Con, adOpenKeyset, adLockOptimistic