如何在Visual Basic 2012中使用mdb数据库中的数据填充列表框?

时间:2017-12-18 20:29:34

标签: vb.net listbox

我正在使用Visual Basic 2012制作学生档案,以进行计算任务。

我有一个组合框,里面有两门课程:计算机和商务。 (在表格的右侧,附图)。此外,按下的列表按钮应根据组合框中选择的课程显示.mdb数据库中的学生。

Form

如何使用我的数据库(我有)中的学生填充列表框?

以下更准确的是我到目前为止的代码:

Public Class Form1  Dim co As New ADODB.Connection  Dim rs As New ADODB.Recordset  Dim确认As Integer

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    co.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Documents\ProfileDB.mdb;Persist Security Info=False")
    rs.Open("Select * from ProfileTBL", co, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic)
    Combo1.Items.Add("Computer Technology")
    Combo1.Items.Add("Business Management")
    display()
End Sub

Sub display()
    TextBox1.Text = rs.Fields.Item("FirstName").Value
    TextBox2.Text = rs.Fields.Item("Surname").Value
    Combo1.Text = rs.Fields.Item("Course").Value
    TextBox4.Text = rs.Fields.Item("Phone").Value
End Sub


Private Sub addnew_Click(sender As Object, e As EventArgs) Handles addnew.Click
    rs.AddNew()
    clear()
End Sub

Sub clear()
    TextBox1.Text = ""
    TextBox2.Text = ""
    Combo1.Text = "Select Course"
    TextBox4.Text = ""
End Sub

Private Sub Savebtn_Click(sender As Object, e As EventArgs) Handles Savebtn.Click
    rs.Fields("FirstName").Value = TextBox1.Text
    rs.Fields("Surname").Value = TextBox2.Text
    rs.Fields("Course").Value = Combo1.Text
    rs.Fields("Phone").Value = TextBox4.Text
    MsgBox("Data is saved successfully.", vbInformation)
    rs.Update()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    rs.MovePrevious()
    If rs.BOF Then
        rs.MoveLast()
        display()
    Else
        display()
    End If
End Sub


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    rs.MoveNext()
    If Not rs.EOF Then
        display()
    Else
        rs.MoveFirst()
        display()
    End If
End Sub

Private Sub deletebtn_Click(sender As Object, e As EventArgs) Handles deletebtn.Click
    confirm = MsgBox("Do you want to delete the Student Profile", vbYesNo + vbCritical, "Deletion Confirmation")
    If confirm = vbYes Then
        rs.Delete()
        MsgBox("Record has been Deleted successfully", vbInformation, "Message")
        rs.Update()
        Refresh()
        clear()

    Else
        MsgBox("Profile Not Deleted!", vbInformation, "Message")
    End If
End Sub



Private Sub findbtn_Click(sender As Object, e As EventArgs) Handles findbtn.Click
    rs.Close()
    rs.Open("Select * from ProfileTBL where Phone='" + TextBox4.Text + "'", co, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic)
    If Not rs.EOF Then
        display()
        reload()
    Else
        MsgBox("Record Profile not found!", vbInformation)
    End If

End Sub

Sub reload()
    rs.Close()
    rs.Open("Select * from ProfileTBL", co, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic)
End Sub


Private Sub listbtn_Click(sender As Object, e As EventArgs) Handles listbtn.Click


End Sub

结束班

1 个答案:

答案 0 :(得分:0)

可能如下所示:

{
  //...
  devtool: 'inline-source-map',
  module: {
    rules: [
      //...
      {
        test: /\.js$/,
        use: ["source-map-loader"],
        exclude: [/node_modules/],
        enforce: "post"
      }
    ]
  }
}