我已经制作了名为" ComeGo"在SQL Server中通过MS Visual Studio,它有12列
(
[CGID] INT NOT NULL PRIMARY KEY,
[CGDate] DATETIME2 NULL,
[CGTime] DATETIME2 NULL,
[CGUserName] NVARCHAR(MAX) NULL,
[CGComeDate] DATETIME2 NULL,
[CGComeTime] DATETIME2 NULL,
[CGComeNotes] NVARCHAR(MAX) NULL,
[CGGODate] DATETIME2 NULL,
[CGGOTime] DATETIME2 NULL,
[CGGONotes] NVARCHAR(MAX) NULL,
[CGDefference] NVARCHAR(MAX) NULL,
[ActionBy] NVARCHAR(MAX) NULL
)
Dim ComeGoCheck As String
ComeGoCheck = "SELECT COUNT(*) FROM ComeGo WHERE CGUserName=@CGUserName AND CGGoDate=@CGGoDate"
Dim cmd As SqlCommand = New SqlCommand(ComeGoCheck, Con)
Dim query As Integer
cmd.Parameters.Add("@CGUserName", SqlDbType.VarChar).Value = GoForm_CGUserName_TextBox.Text
cmd.Parameters.Add("@CGGoDate", SqlDbType.Date).Value = GoForm_CGGoDate_DateTimePicker.Value
Con.Open()
query = CInt(cmd.ExecuteScalar())
Con.Close()
If query > 0 Then
MsgBox("لقد تم تسجيل انصراف الموظف مسبقا")
Con.Close()
Else
GoForm_DataGridView(7, GoForm_DataGridView.CurrentRow.Index).Value = Now.Date
GoForm_DataGridView(8, GoForm_DataGridView.CurrentRow.Index).Value = Now
'Count TimeDiff Between DateCome And DateGo
GoForm_DataGridView(10, GoForm_DataGridView.CurrentRow.Index).Value = DateDiff(DateInterval.Minute, GoForm_DataGridView(5, GoForm_DataGridView.CurrentRow.Index).Value, GoForm_DataGridView(8, GoForm_DataGridView.CurrentRow.Index).Value) / 60
ComeGoCMD = New SqlCommand(" Update ComeGo SET
CGDefference = " & GoForm_DataGridView(10, GoForm_DataGridView.CurrentRow.Index).Value & ",
CGGODate = '" & GoForm_DataGridView(7, GoForm_DataGridView.CurrentRow.Index).Value & "',
CGGOTime = '" & GoForm_DataGridView(8, GoForm_DataGridView.CurrentRow.Index).Value & "',
CGGONotes = '" & GoForm_DataGridView(9, GoForm_DataGridView.CurrentRow.Index).Value & "'
where
CGID = " & GoForm_DataGridView(0, GoForm_DataGridView.CurrentRow.Index).Value & "", Con)
Con.Open()
ComeGoCMD.ExecuteNonQuery()
Con.Close()
'Show Message Box
MsgBox("User Go Registred")
'Reload ComeGo Table With New UpDates
Load_ComeGo()
Con.Close()
End If
ComeGoCMD.ExecuteNonQuery()
从字符串转换日期和/或时间时,转换失败