我遇到了问题,但不知道到底有什么问题,我的代码如下:
Imports System.Data.SqlClient
Imports System.Data
Public Class FormAdd
Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
FormAdmin.Show()
Me.Hide()
End Sub
Private Sub btnAdd_Click(ByRef Success As String, ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Call AddUser(Success)
MsgBox(" " & Success & " ")
End Sub
Private Sub AddUser(ByRef Success As String)
lblAdmin.Text = Str(chkAdminAccount.Checked)
Dim con As New SqlConnection
Dim lrd As SqlDataReader
Dim inscmd As New SqlCommand
inscmd.Parameters.AddWithValue("@Username", txtUsername.Text.Trim())
txtUsername.Text = txtUsername.Text
inscmd.Parameters.AddWithValue("@Password", txtPassword.Text.Trim)
txtPassword.Text = txtPassword.Text
inscmd.Parameters.AddWithValue("@Name", (txtName.Text.Trim))
txtName.Text = txtName.Text
inscmd.Parameters.AddWithValue("@AdminAccount", lblAdmin.Text.Trim)
lblAdmin = lblAdmin
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Alwyn\Desktop\Computing A2 Alwyn\Comp4ProjectRoomBookingSystem\WindowsApplication1\WindowsApplication1\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
Try
con.Open()
inscmd.CommandText = "INSERT INTO Admin (Username, Password, Name, AdminAccount) VALUES (@Username, @Password, @Name, @AdminAccount)"
inscmd.Connection = con
inscmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Could not add User" & ex.Message & " ")
Finally
con.Close()
inscmd.Parameters.Clear()
Success = "User has been added"
End Try
End Sub
End Class
如果您能提供帮助,将不胜感激错误消息如下:
方法“Private Sub btnAdd_Click(ByRef Success As String, sender As Object, e As System.EventArgs)”无法处理事件“Public Event Click(sender As Object, e As System.EventArgs)”,因为它们没有兼容的签名。C:\Users\Alwyn\Desktop\Computing A2 Alwyn\Comp4ProjectRoomBookingSystem\WindowsApplication1\WindowsApplication1\FormAdd.vb 10 130 WindowsApplication1
提前谢谢了。