Private Sub FrmCarNo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'TimeRecDataSet.HDDESC' table. You can move, or remove it, as needed.
Try
CnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=TimeRec.mdb;"
With Cnn
If .State = ConnectionState.Open Then Close()
.ConnectionString = CnnString
.Open()
.Close()
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'Me.HDDESCTableAdapter.Fill(Me.TimeRecDataSet.HDDESC)
MDY = Date.Today
yy = Date.Now.Year
MMDD = MDY.ToString("MMdd")
YMD = yy & MMDD
End Sub
Public Sub WriteData(ByVal myConnString As String)
Try
With Cnn
If .State = ConnectionState.Open Then Close()
.ConnectionString = CnnString
.Open()
End With
QRunning(CnnString)
ID = Trim(YMD) & Trim(Seq)
SqlIns1 = "INSERT INTO HDDESC (ID, CARNO, COMPANY, DATEIN, PROVINCE, DONO) " & _
"VALUES ('" & Trim(ID) & "','" & Trim(TxtCarno.Text) & "','" & Trim(TxtCom.Text) & "','" & Trim(TxtDat.Text) & "','" & Trim(TxtProv.Text) & "','" & Trim(TxtDO.Text) & "')"
Dim OleCommand As New OleDbCommand(SqlIns1, Cnn)
With OleCommand
.CommandType = CommandType.Text
.CommandText = SqlIns1
.Connection = Cnn
.ExecuteNonQuery()
End With
icount = OleCommand.ExecuteNonQuery()
MessageBox.Show(icount)
Catch ex As Exception
MsgBox("Record can not insert Error (" & ex.Message & ")")
End Try
Cnn.Close()
End Sub