我是一个ing学习VB的,想知道怎么实现用VB连接SQL?

解决方案 »

  1.   

    adodb
    adodc
    看看msdn就知道了
      

  2.   

    Public Con As New Connection
    Public re As New recordset
    Con.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=***;PASSWORD=***;Initial Catalog=***;Data Source=***"
    Con.Open
    re.ActiveConnection = Con
    re.Open "select "
    while not re.eof
        '........
    re.movenext
    wend
    if re.State = adStateOpen Then re.Close
      

  3.   

    '改一下楼上的
    Public Con As New adodb.Connection     '定义数据库连接对象
    Public re As New adodb.recordset       '定义记录集对象'说明:User ID-SQL Server用户名;PASSWORD-登录密码;Data Source-数据库所在主机名(或IP);Initial Catalog-数据库
    Con.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=***;PASSWORD=***;Initial Catalog=***;Data Source=***"
    Con.Open      '连接数据
    re.ActiveConnection = Con      '设置记录集的连接对象
    re.Open "select "        '打开记录集
    while not re.eof         '遍历记录集 re.eof 表示到记录集未尾
        '........
    re.movenext
    wend
    if re.State = adStateOpen Then re.Close        '如果记录集当前的状态为打开,则关闭它