 |
|
[.NET]
[VB.net] insert ข้อมูลงในฐานข้อมูลฃแล้วมันเออเร่ออะครับ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
01. Imports System.Data.OleDb
02. Dim myconnection As OleDbConnection = New OleDbConnection()
03. myconnection.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=c:\AccessDatabase.mdb"
04. myconnection.Open()
05. Dim statement As String
06. 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 & "')"
07. Dim mycommand As OleDb.OleDbCommand
08. mycommand = New OleDbCommand(statement, myconnection)
09. mycommand.ExecuteNonQuery()
10. myconnection.Close()

Tag : .NET, Ms Access
|
|
 |
 |
 |
 |
Date :
2012-02-22 09:22:26 |
By :
bank |
View :
1184 |
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)
01. Imports System.Data.OleDb
02. Public Class addlabor
03.
04. Private Sub addlabor_Load( ByVal sender As System. Object , ByVal e As System.EventArgs) Handles MyBase .Load
05.
06. End Sub
07.
08. Private Sub Button1_Click( ByVal sender As System. Object , ByVal e As System.EventArgs) Handles Button1.Click
09. Dim myconnection As OleDbConnection = New OleDbConnection()
10. myconnection.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=c:\AccessDatabase.mdb"
11. myconnection.Open()
12. Dim statement As String
13. 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 & "')"
14. Dim mycommand As OleDb.OleDbCommand
15. mycommand = New OleDbCommand(statement, myconnection)
16. mycommand.ExecuteNonQuery()
17. myconnection.Close()
18. End Sub
19. End Class
|
 |
 |
 |
 |
Date :
2012-02-22 14:58:09 |
By :
noom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|