从字符串转换日期和/或时间时转换失败。我的类型数据列是时间(7)
我的代码是
Protected Sub insertdata()
Dim cls As New Class1
cls.openconnections()
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = cls.cn
cmd.CommandText = "Insert Into Schedule (Room ,Hostel,Tanggal,Jam)"
cmd.CommandText &= "Values (@room,@hostel,@tanggal,@jam:@menit:00)"
cmd.Parameters.AddWithValue("@hostel", listhotelx.SelectedValue)
cmd.Parameters.AddWithValue("@room", listroomx.SelectedValue)
cmd.Parameters.AddWithValue("@tanggal", Calendar1.SelectedDate.ToShortDateString)
cmd.Parameters.AddWithValue("@jam", jam.SelectedValue)
cmd.Parameters.AddWithValue("@menit", menit.SelectedValue)
cmd.ExecuteNonQuery()
cls.closeconnection()
End Sub
感谢您的帮助。