 |
|
[VB.net] insert ข้อมูลงในฐานข้อมูลฃแล้วมันเออเร่ออะครับ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Data.OleDb
Dim myconnection As OleDbConnection = New OleDbConnection()
myconnection.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=c:\AccessDatabase.mdb"
myconnection.Open()
Dim statement As String
statement = "insert into labor(laborcode,name,surname,department,company,phone,position,email,status,address) values('" & laborcode.Text & "','" & namelabor.Text & "','" & surname.Text & "','" & department.Text & "','" & company.Text & "','" & phone.Text & "','" & position.Text & "','" & email.Text & "','" & status.Text & "','" & address.Text & "')"
Dim mycommand As OleDb.OleDbCommand
mycommand = New OleDbCommand(statement, myconnection)
mycommand.ExecuteNonQuery()
myconnection.Close()

Tag : .NET, Ms Access
|
|
 |
 |
 |
 |
Date :
2012-02-22 09:22:26 |
By :
bank |
View :
1204 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา Code มาด้วยครับ 
|
 |
 |
 |
 |
Date :
2012-02-22 09:36:22 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
code ข้างบนอะครับ หรือว่าโค๊ดไรหรอครับพี่ พอดี พึ่งเคยเขียนอะครับ
|
 |
 |
 |
 |
Date :
2012-02-22 09:39:19 |
By :
bank |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนั้นรูปภาพครับ 
|
 |
 |
 |
 |
Date :
2012-02-22 09:50:11 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Imports System.Data.OleDb
Public Class addlabor
Private Sub addlabor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myconnection As OleDbConnection = New OleDbConnection()
myconnection.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=c:\AccessDatabase.mdb"
myconnection.Open()
Dim statement As String
statement = "insert into labor(laborcode,namelabor,surname,department,company,phone,position,email,status,address) values('" & laborcode.Text & "','" & namelabor.Text & "','" & surname.Text & "','" & department.Text & "','" & company.Text & "','" & phone.Text & "','" & position.Text & "','" & email.Text & "','" & status.Text & "','" & address.Text & "')"
Dim mycommand As OleDb.OleDbCommand
mycommand = New OleDbCommand(statement, myconnection)
mycommand.ExecuteNonQuery()
myconnection.Close()
End Sub
End Class
|
 |
 |
 |
 |
Date :
2012-02-22 09:55:27 |
By :
bank |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ฐานข้อมูลก็มี
laborcode
namelabor
surname
department
company
phone
position
email
status
address
ชื่อtext box ก็ตั้งเหมือนชื่อฟิลด์ในฐานข้อมูลเลยอะคครับ
|
 |
 |
 |
 |
Date :
2012-02-22 09:58:54 |
By :
bank |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Data.OleDb
Public Class addlabor
Private Sub addlabor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myconnection As OleDbConnection = New OleDbConnection()
myconnection.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=c:\AccessDatabase.mdb"
myconnection.Open()
Dim statement As String
statement = "insert into labor(laborcode,namelabor,surname,department,company,phone,position,email,status,address) values('" & laborcode.Text & "','" & namelabor.Text & "','" & surname.Text & "','" & department.Text & "','" & company.Text & "','" & phone.Text & "','" & position.Text & "','" & email.Text & "','" & status.Text & "','" & address.Text & "')"
Dim mycommand As OleDb.OleDbCommand
mycommand = New OleDbCommand(statement, myconnection)
mycommand.ExecuteNonQuery()
myconnection.Close()
End Sub
End Class
|
 |
 |
 |
 |
Date :
2012-02-22 14:58:09 |
By :
noom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|