Salve, essendo alle prime armi con in VB.NET ho delle difficoltà ad estrarre un indice non numerico per cancellare un utente da un database, in pratica, prima faccio visualizzare tutti gli utenti presenti nel database tramite un datagrid in questo modo:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'----------------------------------------------------------'
Dim ds As DataSet = New DataSet("MyDataSet")
Dim strSql = "Select * From Cliente"
Dim myCommand As New OleDbDataAdapter(strSql, myConnection)
myCommand.Fill(ds, "Cliente")
'----------------------------------------------------------'
Datagrid1.Datasource = ds.Tables("Cliente").DefaultView
DataBind()
End Sub
Poi ho una funzione chiamata DELETE che in teoria dovrebbe cancellare un utente quando ci clicco sopra. Il problema sta che la mia tabella cliente ha come chiave primaria non un ID unico ma un campo chiamato LOGIN che ovviamente è una stringa, ecco la funzione:
Sub Datagrid1_Delete(ByVal obj As Object, ByVal e As DataGridCommandEventArgs)
Dim strSql As String = "DELETE FROM Cliente WHERE Login = " & e.Item.ItemIndex
ExecuteStatement(strSql)
End Sub
Il problema è che se uso e.Item.ItemIndex mi estrare un indice numerico, come dovrei fare per estrarre invece una stringa?
Grazie Rudy![]()