list = "select * from dep"
da = New OleDbDataAdapter(list, objConn)
da.Fill(dc)
With dep_id
.DisplayMember = dc.Columns.Item("dep_name").ColumnName
.ValueMember = dc.Columns.Item("dep_id").ColumnName
.DataSource = dc
End With
data = "insert into com(com_id,com_name,com_type,dep_id) values ('" & com_id.Text & "','" & com_name.Text & "','" & com_type.Text & "','" & dep_id.Text = dep_id.ValueMember & "')"
Try
With cmddata
.CommandType = CommandType.Text
.CommandText = data
.Connection = conn
.ExecuteNonQuery()
MsgBox("เพิ่มข้อมูลเรียบร้อยแล้ว")
End With
Catch ex As Exception
MsgBox("ไม่สามารถเพิ่มข้อมูลได้")
End Try
ขอบคุณครับ
Tag : .NET, Ms Access, VBScript, Web (ASP.NET), Win (Windows App), VB.NET