我为英语幼儿园创建了一个学习应用程序,我被困在编辑表格中,插入有关唱一首歌的数据......
这是我的程序视图:
Translate
Tambah = Add
Ubah = Edit
Simpan = Save
Batal = Cancel
Hapus = Delete
Cari = Find
现在问题是,当我点击SIMPAN(SAVE)时,没有任何反应,我尝试再次点击SAVE,显示如下错误
以下是编码:
Public Class frmeditlearning
Dim baru, valid As String
Dim id1, judul1, video1, databaru As String
Dim cmd1 As New OleDbCommand(databaru, mycon)
Private Sub btntambahsing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntambahsing.Click
'This is button for ADD when get clicked
txtjudul.Enabled = True
txtvideo.Enabled = True
txtid.Clear()
txtid.Select()
btnsingcarivideo.Enabled = True
btnsimpansing.Enabled = True
btnbatalsing.Enabled = True
btnubahsing.Enabled = False
btnhapussing.Enabled = False
baru = True
btntambahsing.Enabled = False
End Sub
Private Sub btnsimpansing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpansing.Click
If txtid.Text = "" Or txtjudul.Text = "" Or txtvideo.Text = "" Then
MessageBox.Show("Empty textbox is not allowed!", "EMPTY TEXTBOX", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
If baru = True Then
mycon.Open()
Dim noid, str As String
str = "Select id from sing where (id = '" & txtid.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, mycon)
dr = cmd.ExecuteReader
While dr.Read
noid = dr("id").ToString
If txtid.Text = noid Then
mycon.Close()
MessageBox.Show("SAME ID CANNOT USED!", "DUPLICATE ID", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
Else
If Not (txtid.Text = noid) Then
mycon.Open()
id1 = txtid.Text
judul1 = txtjudul.Text
video1 = txtvideo.Text
databaru = "INSERT INTO sing (id,judul,video) values(@id,@judul,@video)"
cmd1.Parameters.AddWithValue("@id", id1)
cmd1.Parameters.AddWithValue("@judul", judul1)
cmd1.Parameters.AddWithValue("@video", video1)
cmd1.ExecuteNonQuery()
mycon.Close()
btnbatalsing.PerformClick()
End If
End If
End While
End If
End Sub
提前致谢,对不起,如果我的英语不好。