请高手指教
我想删除数据表中的一条记录,可为什么她说我“标准表达式中数据类型不匹配”和“至少一个参数没有被指定值”
以下是我的删除代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim mainform As New Form3()
If txtID.ReadOnly() = True And txtName.ReadOnly() = False Then
If txtName.Text = "" Then
MessageBox.Show("你还没有输入姓名!", "info", MessageBoxButtons.OK)
Else
OleDbCommand1.CommandText = "delete from HousingCard where HousingMaster='" + txtName.Text + "'"
OleDbConnection1.Open()
OleDbCommand1.ExecuteNonQuery()
MessageBox.Show("已经删除成功!", "info", MessageBoxButtons.OK)
Me.Close()
End If
ElseIf txtID.ReadOnly() = False And txtName.ReadOnly() = True Then
If txtID.Text = "" Then
MessageBox.Show("你还没有输入ID!", "info", MessageBoxButtons.OK)
Else
OleDbCommand1.CommandText = "delete from HousingCard where HousingCardID='" + txtID.Text + "'"
OleDbConnection1.Open()
OleDbCommand1.ExecuteNonQuery()
MessageBox.Show("已经删除成功!", "info", MessageBoxButtons.OK)
Me.Close()
End If
End If
End Sub
问题点数:0、回复次数:2Top
1 楼rock29(rock)回复于 2003-11-08 16:55:30 得分 0
只有这些代码是判断不出来的,建议你在两个else(删除的那个)中使用try..catch..end try结构看看是哪处有问题.
我估计是HousingCardID可能是integer型,而你用了char型Top
2 楼fanyli(李咏)回复于 2003-11-08 17:05:40 得分 0
OleDbCommand1.CommandText = "delete from HousingCard where HousingMaster='" + txtName.Text + "'"
OleDbCommand1.CommandText = "delete from HousingCard where HousingCardID='" + txtID.Text + "'"
以上该为
OleDbCommand1.CommandText = "delete from HousingCard where HousingMaster='" & txtName.Text & "'"
OleDbCommand1.CommandText = "delete from HousingCard where HousingCardID='" & txtID.Text & "'"
来试一下!
Top




