|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
[VB] Controllo su lettura Database con " IsDBNull "
SU VB.NET:
Questa Sub popola una ListView() multicolonna, selezionando un rigo si richiama la Sub la cui popola la ListView() e utilizza l'ID che trova nel SubItem della ListView() per eseguire la giusta Query che serve a me. Cosa sto' sbagliando??? Perche continua a darmi l'errore: " Nessun dato esistente per la riga/colonna. " Codice:
Private Sub PopoloDatiCliente()
If lvwResoconto.SelectedItems.Count > 0 Then
Dim ID_Cliente As Integer = lvwResoconto.SelectedItems.Item(0).SubItems(1).Text
conn1.Open()
Dim comm1 As New OleDbCommand("SELECT * FROM Clienti WHERE ID = " & ID_Cliente & "", conn1)
Dim read1 As OleDbDataReader = comm1.ExecuteReader
read1.Read()
If Not IsDBNull(read1("RagSoc")) Then txtRagSoc.Text = read1("RagSoc")
If Not IsDBNull(read1("Nome")) Then txtNome.Text = read1("Nome")
If Not IsDBNull(read1("Cognome")) Then txtCognome.Text = read1("Cognome")
If Not IsDBNull(read1("Indirizzo")) Then txtIndirizzo.Text = read1("Indirizzo")
If Not IsDBNull(read1("Citta")) Then txtCitta.Text = read1("Citta")
If Not IsDBNull(read1("Cap")) Then txtCap.Text = read1("Cap")
If Not IsDBNull(read1("Zona")) Then txtZona.Text = read1("Zona")
If Not IsDBNull(read1("Tel")) Then txtTel.Text = read1("Tel")
If Not IsDBNull(read1("Fax")) Then txtFax.Text = read1("Fax")
If Not IsDBNull(read1("Email")) Then txtEmail.Text = read1("Email")
If Not IsDBNull(read1("Url")) Then txtUrl.Text = read1("Url")
conn1.Close()
End If
End Sub
eppure quella funzione "IsDBNull" serve per ovviare all'errore del campo vuoto nella tabella del Database........ |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Feb 2001
Città: Nordest
Messaggi: 217
|
Ma la query è corretta? Sei sicuro che ti restituisce un record?
|
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
Certo se sto attento a non salvare record vuoti funziona tutto......
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 22:39.



















