pros and master out there please have a look on my code, i do not how to solve my problem regarding to get (datevalue) and insert into database, i had try my best to custom code them out but the inserted (datevalue) still with time '12:00:00'. please help me!!!
Form load part
Private Sub Admin_and_GA_Matter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "dd MMM yyyy"
DateTimePicker2.Format = DateTimePickerFormat.Custom
DateTimePicker2.CustomFormat = "dd MMM yyyy"
End Sub
insert part
Private Sub insertinto()
Dim insert1 As String = "INSERT INTO AGITbl (CreateBy, StartDate, CloseDate, StartTime, CloseTime, Contentx, Remark, Status, ShowOnB) VALUES (@CreateBy, @StartDate, @CloseDate, @StartTime, @CloseTime, @Contentx, @Remark, @Status, @ShowOnB)"
Dim cmd As New SqlCommand(insert1, connection)
cmd.Parameters.AddWithValue("@CreateBy", Label10.Text.Trim)
cmd.Parameters.AddWithValue("@StartDate", DateTimePicker1.Value.ToShortDateString)
cmd.Parameters.AddWithValue("@CloseDate", DateTimePicker2.Value.ToShortDateString)
cmd.Parameters.AddWithValue("@StartTime", DateTimePicker3.Value.ToShortTimeString)
cmd.Parameters.AddWithValue("@CloseTime", DateTimePicker4.Value.ToShortTimeString)
cmd.Parameters.AddWithValue("@Contentx", RichTextBox1.Text.Trim)
cmd.Parameters.AddWithValue("@Remark", RichTextBox2.Text.Trim)
cmd.Parameters.AddWithValue("@Status", Label7.Text.Trim)
cmd.Parameters.AddWithValue("@ShowOnB", CInt(Label9.Text))
If RichTextBox1.Text = "" And RichTextBox2.Text = "" And Label7.Text = "" And Label9.Text = 2 Then
MsgBox("blank content not allow to send")
ElseIf RichTextBox1.Text IsNot Nothing And RichTextBox2.Text IsNot Nothing And Label7.Text IsNot Nothing And Label9.Text <> 2 Then
If connection.State = ConnectionState.Closed Then
connection.Open()
End If
cmd.ExecuteNonQuery()
MsgBox("Information sent")
connection.Close()
RichTextBox1.Text = ""
RichTextBox2.Text = ""
Label7.Text = ""
Label9.Text = ""
Me.RadioButton1.Checked = False
Me.RadioButton2.Checked = False
Me.RadioButton3.Checked = False
Me.RadioButton4.Checked = False
Me.RadioButton5.Checked = False
End If
additional load out codes:
Public Sub loadalll()
Dim sqlq As String = "SELECT * FROM AGITbl"
Dim sqlcmd As New SqlCommand
Dim sqladpt As New SqlDataAdapter
Dim tbl As New DataTable
With sqlcmd
.CommandText = sqlq
.Connection = connection
End With
With sqladpt
.SelectCommand = sqlcmd
.Fill(tbl)
End With
DataGridView1.Rows.Clear()
For i = 0 To tbl.Rows.Count - 1
With DataGridView1
.Rows.Add(tbl.Rows(i)("AGINO"), tbl.Rows(i)("CreateBy"), tbl.Rows(i)("StartDate"), tbl.Rows(i)("CloseDate"), tbl.Rows(i)("StartTime"), tbl.Rows(i)("CloseTime"), tbl.Rows(i)("Contentx"), tbl.Rows(i)("Remark"), tbl.Rows(i)("Status"), tbl.Rows(i)("ShowOnB"))
End With
Next
connection.Close()
End Sub
A normal load out, show on datagridview!!!