又来求编程的问题了,这次是在VB里面用SQL语句的

  • 天才GK
    老师给了一个例子是读取database文件的
    我现在想添加或者删除数据怎么弄?
    我的读取代码如下:
    Dim StrMemoryConnection As String = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & _
    Application.StartupPath & "\playlist.mdb"
    Dim strSQLMem As String
    Dim dtMem As New DataTable()
    Dim intTotalRows As Integer
    Dim intCurrentRow As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    dtMem.Clear()
    strSQLMem = ("SELECT * FROM playlist")
    Dim dataAdapter As New OleDb.OleDbDataAdapter(strSQLMem, StrMemoryConnection)
    dataAdapter.Fill(dtMem)
    dataAdapter.Dispose()
    intTotalRows = dtMem.Rows.Count
    intCurrentRow = 1
    DisplayRecord()
    End Sub
    Private Sub DisplayRecord()
    Me.txtOrder.Text = CStr(dtMem.Rows(intCurrentRow)("Order"))
    Me.txtTitle.Text = CStr(dtMem.Rows(intCurrentRow)("Title"))
    Me.txtAlbum.Text = CStr(dtMem.Rows(intCurrentRow)("Album"))
    Me.txtArtist.Text = CStr(dtMem.Rows(intCurrentRow)("Contributing artists"))
    Me.txtGenre.Text = CStr(dtMem.Rows(intCurrentRow)("Genre"))
    Me.txtYear.Text = CStr(dtMem.Rows(intCurrentRow)("Year"))
    Me.txtURL.Text = CStr(dtMem.Rows(intCurrentRow)("URL"))
    End Sub
  • 天才GK
    up!!!!!!!!!!
  • 天才GK
    泪目!!!!!
  • W
    Wander
    insert delete update
  • 蕎麦饅头
    Dim con As New ADODB.Connection
    con .Open(StrMemoryConnection )
    con.execute(" 这里插入 sql的insert delete update语句 ")

    =,=大概这样子
  • 天才GK
    ADODB这个要添加控件的?
    不会用。。。