none
哪位老大给提供个vb2005链接sql2000,插入记录的简单例子 RRS feed

答案

  • 改用VB9吧,里面有一项叫LinQ的技术,操作起来很简单,

     

    Private db As DataClassesLINQtoSQLNorthWindDataContext  ‘引用数据源

        Private Sub AddButton_Click(ByVal sender As System.Object, _
                                ByVal e As System.EventArgs) _
                                Handles AddButton.Click

    ‘申明一个用于存储一条记录的变量
            Dim cust As New Customers With { _
              .City = "Wellington", _
              .CompanyName = "Blue Yonder Airlines", _
              .ContactName = "Jill Frank", _
              .Country = "New Zealand", _
              .CustomerID = "JILLF"}

    ’添加到临时表

    db.Customers.add(cust)

            Try

    ‘存储到数据库
                db.SubmitChanges()
            Catch
                ' Handle exception.
            End Try

    ’刷新

            RefreshData()
        End Sub


    以上注解是本人理解后的,可能与帮助中注解的文字有出入。

    2008年3月13日 3:01