daosjohnpeter05
Addict
Hello mga ka PHC, meron ako prob sa ginagawa kong project. Sa SQL query at sa datatypes. Yung column ko kasi sa database ay may datatype na "time (7)", gusto ko i insert yung string value ng timeLbl.Text sa database kasabay ng data ng employee, kaso ang nagiging problema ko palagi ay invalid conversion of datetime from string.
Ginawa ko na yung sa conversion ng variable gamit ang sql parameters pero wala pa din, eto ang buong code ko ..Pasensya na bago lang ako sa MSSQL, thanks ^_^
Private Sub timeIn()
Try
connection = New SqlConnection(constr)
command = connection.CreateCommand
command.CommandText = "INSERT INTO Clocks (employeeID, firstName, middleName, lastName, position, dateIn, timeIn) VALUES ('" & idTxt.Text & "', '" & firstnameTxt.Text & "', '" & middlenameTxt.Text & "', '" & lastnameTxt.Text & "', '" & positionTxt.Text & "', '" & dateIn & "', '" & Convert.ToDateTime(timeLbl.Text) & "')"
connection.Open()
command.ExecuteReader()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Ginawa ko na yung sa conversion ng variable gamit ang sql parameters pero wala pa din, eto ang buong code ko ..Pasensya na bago lang ako sa MSSQL, thanks ^_^
Private Sub timeIn()
Try
connection = New SqlConnection(constr)
command = connection.CreateCommand
command.CommandText = "INSERT INTO Clocks (employeeID, firstName, middleName, lastName, position, dateIn, timeIn) VALUES ('" & idTxt.Text & "', '" & firstnameTxt.Text & "', '" & middlenameTxt.Text & "', '" & lastnameTxt.Text & "', '" & positionTxt.Text & "', '" & dateIn & "', '" & Convert.ToDateTime(timeLbl.Text) & "')"
connection.Open()
command.ExecuteReader()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Last edited: