คืออยากบันทึกข้อมูลไปไว้หลายๆตาราง แต่มันติดปัญหา error ตอนบันทึกข้อมูลอ่ะครับ
Imports System.Data
Imports System.Data.OleDb
Public Class FormListSub
Dim ds As New DataSet()
Dim da As OleDbDataAdapter
Dim iRow As Integer
Dim bs As New BindingSource()
Dim WithEvents objCurrencymanager As CurrencyManager
Dim WithEvents tbpractice As CurrencyManager
Private Property cn As OleDbConnection
Private Sub FormList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;user id=admin;password=;data source = C:/project.mdb")
cn.Open()
da = New OleDbDataAdapter("select * from sub", cn)
Try
da.Fill(ds, "sub")
Catch ex As OleDb.OleDbException
MsgBox(ex.Message)
End Try
Sub_no.DataBindings.Add("text", ds.Tables("sub"), "Sub_no")
Sub_that.DataBindings.Add("text", ds.Tables("sub"), "Sub_that")
Sub_date.DataBindings.Add("text", ds.Tables("sub"), "Sub_date")
Sub_from.DataBindings.Add("text", ds.Tables("sub"), "Sub_from")
Sub_up.DataBindings.Add("text", ds.Tables("sub"), "Sub_up")
Dim tblpractice As String
tblpractice = "select * from practice"
da.SelectCommand.CommandText = tblpractice
da.Fill(ds, "practice")
bs.DataSource = ds.Tables("practice")
With ComboBox1
.DataSource = ds.Tables("practice")
.DisplayMember = "pra_name"
.ValueMember = "pra_id"
.DataBindings.Add("SelectedValue", bs, "pra_id")
End With
DataGridView1.DataSource = ds.Tables("sub")
objCurrencymanager = CType(Me.BindingContext(ds.Tables("sub")), CurrencyManager)
tbpractice = CType(Me.BindingContext(ds.Tables("practice")), CurrencyManager)
End Sub
vb อยากทราบการบันทึกข้อมูลไปยังหลายๆตารางในทีเดียวอ่ะครับ
Imports System.Data
Imports System.Data.OleDb
Public Class FormListSub
Dim ds As New DataSet()
Dim da As OleDbDataAdapter
Dim iRow As Integer
Dim bs As New BindingSource()
Dim WithEvents objCurrencymanager As CurrencyManager
Dim WithEvents tbpractice As CurrencyManager
Private Property cn As OleDbConnection
Private Sub FormList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;user id=admin;password=;data source = C:/project.mdb")
cn.Open()
da = New OleDbDataAdapter("select * from sub", cn)
Try
da.Fill(ds, "sub")
Catch ex As OleDb.OleDbException
MsgBox(ex.Message)
End Try
Sub_no.DataBindings.Add("text", ds.Tables("sub"), "Sub_no")
Sub_that.DataBindings.Add("text", ds.Tables("sub"), "Sub_that")
Sub_date.DataBindings.Add("text", ds.Tables("sub"), "Sub_date")
Sub_from.DataBindings.Add("text", ds.Tables("sub"), "Sub_from")
Sub_up.DataBindings.Add("text", ds.Tables("sub"), "Sub_up")
Dim tblpractice As String
tblpractice = "select * from practice"
da.SelectCommand.CommandText = tblpractice
da.Fill(ds, "practice")
bs.DataSource = ds.Tables("practice")
With ComboBox1
.DataSource = ds.Tables("practice")
.DisplayMember = "pra_name"
.ValueMember = "pra_id"
.DataBindings.Add("SelectedValue", bs, "pra_id")
End With
DataGridView1.DataSource = ds.Tables("sub")
objCurrencymanager = CType(Me.BindingContext(ds.Tables("sub")), CurrencyManager)
tbpractice = CType(Me.BindingContext(ds.Tables("practice")), CurrencyManager)
End Sub