1

我是编程新手,并试图通过 youtube 教程学习 VB.net。所以我尝试为“登录”和“创建新帐户”创建单独的表单。登录似乎工作正常。但是,创建帐户对我来说很难成功编码。我遇到的主要问题是“插入”代码。我创建了一个“createnewaccount”表单并将一个数据库连接到它。然后我在“btnsave”下编写了一个代码,这样当人们创建新帐户时,它将被保存到数据库中。这是我不断遇到问题的地方。上面写着“UsersPasswordsTableAdapter1.Insert”的地方一直强调它,程序无法运行。这是我的代码。任何帮助都会有所帮助。

导入系统导入 System.Data 导入 System.Data.OleDb 公共类 CreateNewAccount

Private Sub CreateNewAccount_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.UsersPasswordsTableAdapter1.Fill(Me.UsersPasswordsDataSet1.UsersPasswords)

End Sub

Private Sub btnSaveNewAccount_Click(sender As Object, e As EventArgs) Handles btnSaveNewAccount.Click
    LoginPage.UsersPasswordsTableAdapter1.Insert(Me.TextBox1.Text, Me.TextBox2.Text, Me.TextBox3.Text)
    LoginPage.UsersPasswordsTableAdapter1.Fill(LoginPage.UsersPasswordsDataSet1.UsersPasswords)
    MsgBox("Your Account has been saved successfully", MsgBoxStyle.Information)
    TextBox1.Text = ""
    TextBox2.Text = ""
    TextBox3.Text = ""

End Sub

Private Sub btnBacktoLogin_Click(sender As Object, e As EventArgs) Handles btnBacktoLogin.Click
    Me.Hide()
    LoginPage.Show()

End Sub

结束类

4

0 回答 0