Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
hi all, i have an annoying problem here..
i want to delete selecting rows on my datagridview with connect to excel, but it show message like this "deleting data in a linked table is not supported by this ISAM", any sugestion, help me please

here my code :
VB
'for connect
Dim connstring = "provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\datakaryawanall.xls;Extended Properties=Excel 8.0;"
Public myDate As Date


VB
'delete button
 Try
            Dim SqlQuery As String = "DELETE * from [datakaryawanall] where NIK ='" & txtNIK.Text & "'"
            Dim SqlCommand As New OleDbCommand
            With SqlCommand
                .CommandText = SqlQuery
                .Connection = cn
                .ExecuteNonQuery()
            End With
            MsgBox("Satu Data Karyawan Sudah diHapus")
            Me.RefreshDataView()
            Me.bersih()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try


or help me building query that make all of cell in the row has no value, and when load datagridview not read the blank value, is it possible ??
Posted
Updated 18-Jun-15 1:31am
v2
Comments
Richard Deeming 18-Jun-15 10:08am    
Your code is vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
Akbar Giffary 19-Jun-15 2:32am    
okay so...
can you give me sample for delete please

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900