 |
|
DataGridview จะกำหนด ค่า checkbox ยังไงครับเพื่อลบข้อมูลในฐานข้อมูล |
|
 |
|
|
 |
 |
|
รบกวนพี่ win อีกทีครับ
มัน ERROR ตรงนี้อ่ะครับพี่
Code (VB.NET)
com.ExecuteNonQuery()
แล้ว ตารางผมชื่อ tbl_user และ มี user_id,username,password ครับพี่
จะ where ที่ไหนดีครับ หรือว่าที่ id เหมือนแบบ โค๊ดอันนี้ครับ
Code (VB.NET)
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'UserDataSet.tbl_user' table. You can move, or remove it, as needed.
Me.Tbl_userTableAdapter.Fill(Me.UserDataSet.tbl_user)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As SqlConnection
Dim strConnString As String
strConnString = "Server=ZEROYAKI;Uid=sa;PASSWORD=1234;database=user;"
con = New SqlConnection(strConnString)
con.Open()
Dim com As New SqlCommand()
Dim sql As String
For i As Integer = 0 To DataGridView1.Rows.Count - 2
If DataGridView1.Rows(i).Cells(0).Value IsNot Nothing Then
Dim id As [String] = DataGridView1.Rows(i).Cells(1).Value.ToString()
sql = "delete from tbl_user where id='" & id & "'"
com.Connection = con
com.CommandType = CommandType.Text
com.CommandText = sql
com.ExecuteNonQuery()
End If
Next
End Sub
End Class
รบกวนดูให้อีกทีนะครับ ผมสร้าง ปุ่มมากด ลบ เขียนใน Button1 ถูกแล้วใช่ไหมครับ
(ผมมือใหม่จริงๆครับ ขอความช่วยเหลือ)
|
 |
 |
 |
 |
Date :
2011-08-12 15:23:15 |
By :
ZEROYAKI |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาไฟร์ที่มันรัน ได้มาเลยได้ไหมจะได้ช่วยดูให้ถูกไม่ต้องนั่งงม
|
 |
 |
 |
 |
Date :
2011-08-13 03:46:56 |
By :
wasantec |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Dim id As [String] = DataGridView1.Rows(i).Cells(1).Value.ToString()
ถ้าได้ค่าเป็นอะไรครับ ถ้า id มีค่าก็ลบได้ครับ
|
 |
 |
 |
 |
Date :
2011-08-15 15:44:19 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|