我想用VB+SQL写一个网络的工作平台,需要对SQL数据进行增删改查的操作,可是不知道在vb中如何编写,希望高手能给予指点,希望给出实例代码!

解决方案 »

  1.   

    和VB无关。SQL语句:
    增加 insert into
    删除 delete
    修改 update
    查询 select
      

  2.   

    dim conn as new adodb.connection
    '连接数据库
    With conn
        If .State = adStateOpen Then .Close
        .ConnectionString = "driver=SQL Server;server=计算机名或IP地址;uid=sa;pwd=sa的密码;database=数据库名"
        .CommandTimeout = 0
        .Open
    End With'新增记录:
    conn.execute "insert into 表名(字符字段,数值字段) values('"& 字符变量 &"',"& 数值变量 &")"
    '修改记录:
    conn.execute " update 表名 set ... where ..."
    '删除记录:
    conn.execute "delete from 表名 where ..."