Slette række i DataGridview
HejMed nedenstående kode fylder jeg Datagridview1. Jeg ville imidlertid gerne kunne slette en valgt række OG samtidigt slette data i SQL databasens tabel. Hvordan kan det gøres?
Vh Steen
Public Class FrmHuskeliste
Function BuildCnnStr(ByVal strServer As String, _
ByVal strDatabase As String) As String
Dim strTemp As String
strTemp = "Provider=sqloledb;Data Source=100.46.1.10;Initial Catalog=" & strDatabase & ";USER ID=st;Password=xxx;"
Return strTemp
End Function
Private Sub FrmHuskeliste_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim odData As OleDb.OleDbDataAdapter
Dim dtList As DataTable = New DataTable()
Dim strSQL As String
'-- Create the SQL String
strSQL = "Select * From Huskeliste"
'-- Set up the exception catch
Try
'-- Create an instance of the data adapter, and then fill the data table
odData = New OleDb.OleDbDataAdapter(strSQL, BuildCnnStr("100.46.1.10", "PatientregisteretSQL3;User ID=St;Password=xxx"))
odData.Fill(dtList)
DataGridView1.DataSource = dtList
Catch oexpData As OleDb.OleDbException
MsgBox(oexpData.Message)
End Try
dtList = Nothing
odData = Nothing
End Sub
End Class