 |
|
อยากรุ้วิธีการ connect Database ใน vb 2008 ขอความช่วยเหลือหน่อยค่ะ |
|
 |
|
|
 |
 |
|
ทำได้แล้วค่ะ
แต่ทำไมหนูยังเรียกฐานข้อมูลมาโชว์ในฟอร์มไม่ได้เลยค่ะ
|
 |
 |
 |
 |
Date :
2012-03-23 23:25:09 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา Error มาดูครับ 
|
 |
 |
 |
 |
Date :
2012-03-23 23:44:24 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
ประวัติการแก้ไข 2012-03-24 12:14:39
 |
 |
 |
 |
Date :
2012-03-24 12:13:47 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่คอนเนคดาต้าเบสแล้วนะค่ะ
|
 |
 |
 |
 |
Date :
2012-03-24 12:15:23 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Copy Code มาให้ดูหน่อยครับ เอาทั้งหมดเลยครับ
|
 |
 |
 |
 |
Date :
2012-03-24 12:20:46 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Data
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class ตั้งค่าเบื้องต้นระบบ_ข้อมูลบุคลากร
Private Sub ออกจากระบบToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ออกจากระบบToolStripMenuItem.Click
Me.Hide()
เข้าสู่ระบบ.Show()
End Sub
Private Sub ขอมลลกคาToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลลกคาToolStripMenuItem.Click
Me.Hide()
ตั้งค่าเบื้องต้นระบบ_ข้อมูลลูกค้า.Show()
End Sub
Private Sub ขอมลบคลากรToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลบคลากรToolStripMenuItem.Click
End Sub
Private Sub ขอมลเงนเดอนToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลเงนเดอนToolStripMenuItem.Click
Me.Hide()
ตั้งค่าเบื้องต้นระบบ_ข้อมูลอัตราเงินเดือน.Show()
End Sub
Private Sub ขอมลอตราคาบรการToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลอตราคาบรการToolStripMenuItem.Click
Me.Hide()
ตั้งค่าเบื้องต้นระบบ_ข้อมูลอัตราค่าบริการ.Show()
End Sub
Private Sub ขอมลอปกรณToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลอปกรณToolStripMenuItem.Click
Me.Hide()
ตั้งค่าเบื้องต้นระบบ_ข้อมูลอุปกรณ์.Show()
End Sub
Private Sub ลกคาToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ลกคาToolStripMenuItem.Click
Me.Hide()
การคิดเงินเดือน.Show()
End Sub
Private Sub การเบกใชอปกรณToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles การเบกใชอปกรณToolStripMenuItem.Click
Me.Hide()
การเบิกใช้อุปกรณ์.Show()
End Sub
Private Sub การรบรถToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles การรบรถToolStripMenuItem.Click
Me.Hide()
การให้บริการรับรถคืนรถ_การรับรถ.Show()
End Sub
Private Sub การคดคาบรการToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles การคดคาบรการToolStripMenuItem.Click
Me.Hide()
การให้บริการรับรถคืนรถ_การคิดค่าบริการ.Show()
End Sub
Private Sub การคนรถToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles การคนรถToolStripMenuItem1.Click
Me.Hide()
การให้บริการรับรถคืนรถ_การคืนรถ.Show()
End Sub
Private Sub รปแบบเอกสารToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles รปแบบเอกสารToolStripMenuItem.Click
Me.Hide()
พิมพ์รายงานรูปแบบเอกสาร.Show()
End Sub
Private Sub รปแบบกราฟToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles รปแบบกราฟToolStripMenuItem.Click
Me.Hide()
พิมพ์รายงานรูปแบบกราฟ.Show()
End Sub
Public Sub loadfile()
Dim sqlQuery As String = "select * from personnel"
Dim sqlAdapter As New MySqlDataAdapter
Dim sqlCmd As New MySqlCommand
Dim sqlTable As New DataTable
Dim i As Integer
With sqlCmd
.CommandText = sqlQuery
.Connection = con
End With
With sqlAdapter
.SelectCommand = sqlCmd
.Fill(sqlTable)
End With
For i = 0 To sqlTable.Rows.Count - 1
DataGridView1.Rows.Add(sqlTable.Rows(i)("per_no"), (sqlTable.Rows(i)("per_name")), (sqlTable.Rows(i)("per_sname")), (sqlTable.Rows(i)("per_tel")), (sqlTable.Rows(i)("per_address")), (sqlTable.Rows(i)("per_id")), (sqlTable.Rows(i)("sal_rate_position")))
Next
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
If (TextBox5.Text = "") Then
Return
End If
If (Not IsNumeric(TextBox5.Text)) Then
MsgBox("ใส่ตัวเลขเท่านั้น กรุณาใส่ใหม่")
TextBox5.Clear()
TextBox5.Focus()
End If
End Sub
Private Sub ตั้งค่าเบื้องต้นระบบ_ข้อมูลบุคลากร_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If con.State = ConnectionState.Closed Then
con.Open()
End If
loadfile()
con.Close()
End Sub
End Class
|
 |
 |
 |
 |
Date :
2012-03-24 16:21:54 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยหน่อยนะค่ะอีก1เดือนจะสอบโปรเจคแล้วววววว
|
 |
 |
 |
 |
Date :
2012-03-24 16:23:09 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Connection String อยู่ที่ไหนครับ 
|
 |
 |
 |
 |
Date :
2012-03-24 17:52:10 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2012-03-24 20:06:39 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีจิงๆด้วยแล้วใส่ยังไงอ่าค่ะ
|
 |
 |
 |
 |
Date :
2012-03-24 20:10:50 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่รู้นะว่าพวกชือ object แต่ละตัวมันใช้ภาษาไทยได้ไหม มันจะ compile รู้เรื่องหรือเปล่า เพราะ class, method มันเป็นภาษาไทยหมดแล้ว
|
 |
 |
 |
 |
Date :
2012-03-24 23:03:33 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ออค่ะจาลองเปลี่ยนดูนะค่ะ
|
 |
 |
 |
 |
Date :
2012-03-25 11:55:51 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ได้ครับ แต่ปกติคนไม่ค่อยใช้กันครับ 
|
 |
 |
 |
 |
Date :
2012-03-26 06:39:58 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำทุกวิธีแล้วค่ะ
แต่ก้อยังเชื่อมฐานข้อมูลไม่ได้ซักที
|
 |
 |
 |
 |
Date :
2012-03-26 21:17:02 |
By :
noomnoom1011 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบไปหลายกระทู้แล้วน่ะครับ คิดว่าได้แล้วซะอีก 
|
 |
 |
 |
 |
Date :
2012-03-27 06:32:24 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมจะบันทึกข้อมูล โดยต้องตรวจสอบว่ารหัสซำกันหรือไม่ กับ id ของฐานข้อมูล เราควรเขียนโค้ดยังไงดีครับ
|
 |
 |
 |
 |
Date :
2012-04-05 13:57:06 |
By :
oomeo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Dim con As New MySqlConnection("Server=localhost;User Id=root; Password=.....; Database=.....; Pooling=false")
ลองดูนะครับ
|
 |
 |
 |
 |
Date :
2012-04-10 22:14:15 |
By :
SharpDev |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีความรู้อย่างมากๆ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-04-11 09:11:47 |
By :
tooktaall |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|