各位高手,新人学习,碰到一个问题,本人创建了一个名为新建项目的窗体,确认按键代码如下:
Dim x1 As String = e.Form.Controls("项目编号1").Value
Dim x2 As String = e.Form.Controls("项目名称1").Value
Dim cmd As New SQLCommand
cmd.C
If x1 = "" OrElse x2 = "" Then
Messagebox.show("请输入项目编号和项目名称!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select Top 1 项目编号 From {编号} Where 项目编号 = '" & x1 & "'"
If cmd.ExecuteScalar > "" Then
Messagebox.show("新建项目编号失败,已经能存在同名项目编号!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select Top 1 项目名称 From {编号} Where 项目名称 = '" & x2 & "'"
If cmd.ExecuteScalar > "" Then
Messagebox.show("新建项目名称失败,已经能存在同名项目名称!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Insert Into {编号} ([项目编号],[项目名称],) Values ('"
cmd.CommandText = cmd.CommandText & x1 & "','" & x2 & "')"
If cmd.ExecuteNonQuery = 1 Then '返回1表示增加成功
If Forms("项目管理").Opened Then
With Forms("项目管理").Controls("x2")
.Items.Add("x1")
.SelectedIndex = .Items.Count -1
End With
End If
e.Form.Close()
该使用什么代码,使得创建新项目编号之后,在数据库同行栏“创建时间”内自动填入当天时间
真心求教各位大能帮助解决,不胜感激!找了N多资料,都没法解决,本人能力有限只得求教各位!