 |
|
อยากได้โค้ดการเชื่อม VB2008 กับ ACCESS2007 และตัวอย่างครับผม |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Import System.Data.OleDb
' Insert ข้อมูล
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim cmdSave As OleDbCommand
Dim strSave As String
strSave = "Insert Into Employees (Firstname,LastName) Values ('" & txtFname.Text & "','" & txtLname.Text & "')"
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\EmployeeDB.mdb;User Id=;Password=;"
conn = New OleDb.OleDbConnection(strConn)
conn.Close()
conn.Open()
Try
cmdSave = New OleDbCommand(strSave, conn)
cmdSave.ExecuteNonQuery()
cmdSave.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message.ToString, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub
|
 |
 |
 |
 |
Date :
2011-08-23 11:11:31 |
By :
Jakc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ ใครมีตัวอย่างอีกนำมาเสนอได้นะครับผม
|
 |
 |
 |
 |
Date :
2011-08-23 11:36:58 |
By :
Aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
conn = New OleDb.OleDbConnection(strConn)
conn.Close()
conn.Open()
Try
cmdSave = New OleDbCommand(strSave, conn)
cmdSave.ExecuteNonQuery()
cmdSave.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message.ToString, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
มันหมายความว่ายังไงบ้างครับ
|
 |
 |
 |
 |
Date :
2011-08-23 11:40:16 |
By :
Aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แค่สั่ง execute จาก Command ที่ได้รับมาครับ 
|
 |
 |
 |
 |
Date :
2011-08-23 14:53:11 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับผม แล้วพวก UPDATE DELTE อ่าครับ
|
 |
 |
 |
 |
Date :
2011-08-23 20:57:03 |
By :
Aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แค่เปลี่ยนจาก Insert เป็น Update และ Delete ครับ
|
 |
 |
 |
 |
Date :
2011-08-23 21:16:22 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วการ join ใน ACCESS ทำยังไงอ่าครับ join สัก 3 ตารางอ่าครับ
|
 |
 |
 |
 |
Date :
2011-08-24 00:23:16 |
By :
Aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แบบว่าเขียน ภาษา SQL ยังไงอ่าครับ
|
 |
 |
 |
 |
Date :
2011-08-24 00:24:10 |
By :
Aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim delemp As String
If (TextBox1.Text = "") Then
MessageBox.Show("กรุณาเลืกข้อมูลที่จะลบก่อน", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If MessageBox.Show("คุณต้องการลบจริงๆใช่ไหม", "ยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = MsgBoxResult.Yes Then
Try
delemp = "DELETE ID_Employee FROM Employee WHERE (ID_Employee = '" & TextBox1.Text & "')"
conn.Open()
TextBox1.Enabled = True
With cmd
.CommandType = CommandType.Text
.CommandText = delemp
.Connection = conn
.ExecuteNonQuery()
End With
Catch ex As Exception
MessageBox.Show("ลบข้อมูลไม่ได้ กรุณาตรวจสอบข้อมูลที่เลือก", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
Dim cmddel As New OleDbCommand
Try
Finally
TextBox1.Text = " "
TextBox4.Text = " "
TextBox3.Text = " "
TextBox2.Text = " "
TextBox38.Text = " "
conn.Close()
End Try
MessageBox.Show("ลบข้อมูลเรียบร้อยแล้ว", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
Employeeshow()
TextBox1.Enabled = True
Else
Me.Employeeshow()
End If
End Sub
End Class
อันนี้คือปุ่มที่ผมจะลบข้อมูล แต่มันลบไม่ได้ขึ้น MessageBox.Show("ลบข้อมูลไม่ได้ กรุณาตรวจสอบข้อมูลที่เลือก", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) ที่เป็น Dialog ทำไงดีครับผม
|
 |
 |
 |
 |
Date :
2011-08-24 15:50:19 |
By :
Aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมแนะนำนะครับ ถ้าจะให้การ query ให้ไป query ใน access เลยครับ แล้วค่อยเอามาใช้ได้ชัวครับ
|
 |
 |
 |
 |
Date :
2011-08-24 22:16:21 |
By :
slurpee55555 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วใน access ทำยังไงอ่าครับ ขอตัวอย่างด้วยอ่าครับผม ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2011-08-25 05:07:17 |
By :
Aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แผมอยากรู้ว่าการ insert ที่เดียว 2 ตาราง ในคำสั่งเดียว ทำได้ไหมครับ ถ้าได้ ทำยังไงครับผม
|
 |
 |
 |
 |
Date :
2011-08-25 22:20:26 |
By :
aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เขียน 2 Query ครับ
|
 |
 |
 |
 |
Date :
2011-08-25 22:36:50 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอแบบเป็นตัวอย่างคำสั่งได้ไหมครับผม
|
 |
 |
 |
 |
Date :
2011-08-25 22:42:56 |
By :
aon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

มันรันไม่ผ่าน เป็นเพราะอะไรคับ ขอบคุนคับ
|
 |
 |
 |
 |
Date :
2013-02-12 00:45:45 |
By :
เม่น |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|