Imports System.Data
Imports System.Data.OleDb
Imports System.Data.DataRow
Public Class Class1
Private conn As New OleDbConnection
Private dtread As OleDbDataReader
Private sqlcom As String
Dim CVNo As String
Dim FirstName As String
Dim Lastname As String
Dim OwnTimes As String
Dim Phone As String
Dim DateTimePicker1 As String
Dim Position As String
Dim Saturation As String
Dim StaffTpye As String
Dim Status As String
Dim SubSection As String
Dim date1 As String
Public Sub Connect()
With conn
If .State = ConnectionState.Open Then .Close()
' .ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\paweenawat\Documents\Visual Studio 2010\Projects\test_add_delete_select_update\WindowsApplication7\Database11.accdb"
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\PMCBL_ITINV_V0.8.accdb"
.Open()
End With
End Sub
Public Sub addset(ByVal CVNo As String, ByVal FirstName As String, ByVal Lastname As String, ByVal DateTimePicker1 As String, ByVal Position As Integer, ByVal Saturation As String, ByVal StaffTpye As String, ByVal SubSection As Integer, ByVal status As Integer, ByVal phone As String, ByVal OwnTimes As Integer)
Dim dt As DataTable
Dim dr As DataRow
Dim da As New OleDbDataAdapter
Connect()
Dim ds As New DataSet
dt = ds.Tables("Employer")
dr = dt.NewRow() '<----------------------------
dr("CVNo") = CVNo
dr("OwnTimes") = OwnTimes
dr("ArrivalDate") = DateTimePicker1
dr("StaffType") = StaffTpye
dr("Emp_Saturation") = Saturation
dr("Emp_FirstName") = FirstName
dr("Emp_LastName") = Lastname
dr("Emp_Position") = Position
dr("Emp_SubSection") = SubSection
dr("EmpContactPhone") = phone
dr("Status") = status
dt.Rows.Add(dr)
Dim combd As New OleDbCommandBuilder(da)
da.Update(ds, "Employer")
ds.AcceptChanges()
da.Fill(ds, "Employer")
End Sub
End Class
Tag : ASP.NET Ms Access, Win (Windows App), VB.NET, Windows
Dim ds As New DataSet
^^^^ ds เพิ่งจะ New มาหมาดๆ ไม่มีค่าอะไรเลย
dt = ds.Tables("Employer")
^^^^ dt ก็จะเท่ากับ NoThing ไปด้วย
dr = dt.NewRow()
^^^^ NewRow ก็เลยไม่รู้จะเอาอะไรมา New ให้