lawang code

lawang Code


Tanyakan kode disini

cara menyimpan data yang memiliki type data date (asp.net VB )

ditanyakan oleh ramadhani 3 tahun yang lalu

saya mempunyai coding seperti beritkut :

    Dim kdproj As String = txtkodeproject.Text
    Dim projname As String = txtnama.Text
    Dim anggar As Int32 = txtanggaran.Text
    Dim sdate As Date = txtDate.Text
    Dim sisa As Int32 = txtsisa.Text
    Dim inputstatus As Date = txtstatus_tgl.Text
    Dim status As String = ddlstatus.Text
    Dim persetuju As String = txtpersetujuan.Text
    Dim edate As Date = txtEnddate.Text
Dim posisi As Date = txtposisi.Text
    Dim iddiv As String = ddlDivisi.Text
    Dim idsubdiv As String = ddlSubDivisi.Text
    Dim ket As String = txtketerangan.Text
    Dim hisket As String = listhistory.Text
    Dim iddiv1 As String = ddldivisi1.Text
    Dim idsubdiv1 As String = ddlsubdiv1.Text
    Dim constr As String = ConfigurationManager.ConnectionStrings("MyConnCompany").ConnectionString
    sdate = Convert.ToDateTime(txtDate.Text).ToString("DD/MM/YYYY HH:MI:SS")
    edate = Convert.ToDateTime(txtEnddate.Text).ToString("DD/MM/YYYY HH:MI:SS")
    posisi = Convert.ToDateTime(txtposisi.Text).ToString("DD/MM/YYYY HH:MI:SS")
    inputstatus = Convert.ToDateTime(txtstatus_tgl.Text).ToString("DD/MM/YYYY HH:MI:SS")

    Using con As New OracleConnection(constr)
        Using cmd As New OracleCommand("Insert Into SUMPROJ (KD_PROJECT,PROJECT_NAME,ANGGARAN,START_DATE,SISA_ANGGARAN,INPUT_STATUS_TANGGAL,STATUS,PERSETUJUAN,END_DATE,POSISI_TANGGAL,ID_DIVISI_MINTA,ID_SUBDIV_MINTA,KETERANGAN,HISTORY_KETERANGAN,ID_DIVISI_MOHON,ID_SUBDIV_MOHON) " & _
                                       "VALUES (:kdproj,:projname,:anggar,:sdate,:sisa,:inputstatus,:status,:persetuju,:edate,:ket,:hisket,:iddiv1,:idsubdiv1)")
            Try
                If con.State <> ConnectionState.Open Then
                    con.Open()
                End If
                Using sda As New OracleDataAdapter()
                    cmd.Parameters.Add(":kdproj", OracleDbType.Varchar2).Value = txtkodeproject.Text
                    cmd.Parameters.Add(":projname", OracleDbType.Varchar2).Value = txtnama.Text
                    cmd.Parameters.Add(":anggar", OracleDbType.Int32).Value = txtanggaran.Text
                    cmd.Parameters.Add(":sdate", OracleDbType.Date).Value = DateTime.Parse(txtDate.Text)
                    cmd.Parameters.Add(":sisa", OracleDbType.Int32).Value = txtsisa.Text
                    cmd.Parameters.Add(":inputstatus", OracleDbType.Date).Value = DateTime.Parse(txtstatus_tgl.Text)
                    cmd.Parameters.Add(":status", OracleDbType.Varchar2).Value = ddlstatus.Text
                    cmd.Parameters.Add(":persetuju", OracleDbType.Varchar2).Value = txtpersetujuan.Text
                    cmd.Parameters.Add(":edate", OracleDbType.Date).Value = DateTime.Parse(txtEnddate.Text)
                    cmd.Parameters.Add(":posisi", OracleDbType.Date).Value = DateTime.Parse(txtposisi.Text)
                    cmd.Parameters.Add(":iddiv", OracleDbType.Varchar2).Value = ddlDivisi.Text
                    cmd.Parameters.Add(":idsubdiv", OracleDbType.Varchar2).Value = ddlSubDivisi.Text
                    cmd.Parameters.Add(":ket", OracleDbType.Varchar2).Value = txtketerangan.Text
                    cmd.Parameters.Add(":hisket", OracleDbType.Varchar2).Value = listhistory.Text
                    cmd.Parameters.Add(":iddiv1", OracleDbType.Varchar2).Value = ddldivisi1.Text
                    cmd.Parameters.Add(":idsubdiv1", OracleDbType.Varchar2).Value = ddlsubdiv1.Text
cmd.Connection = con
                    cmd.ExecuteNonQuery()
                    Me.txtError.Text = "Record Insert Sucessful."
                    Me.txtError.Visible = True
                    cmd.ExecuteNonQuery()
                    con.Close()
                End Using
            Catch ex As Exception
                Me.txtError.Visible = True
                Me.txtError.Text = "Record Cannot Insert : Error (" & ex.Message & ")"

            End Try
        End Using


akan tetapi muncul pesan error datetime format not valid..

Anda harus login terlebih dahulu untuk memberikan komentar

Recent Tag

X 6
X 48
X 14
X 10
X 1
X 5
X 4
X 18
X 10

Bantuan

Help

Feedback

Help