Pagina 1 di 4 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 31
  1. #1
    Utente di HTML.it L'avatar di lory38
    Registrato dal
    Dec 2010
    Messaggi
    214

    [vb.net] errore matrice

    Salve,

    mi da errore "Errore durante la creazione del form. Per informazioni dettagliate vedere Exception.InnerException. Errore: Indice oltre i limiti della matrice."
    codice:
    For i As Integer = 1 To 25
    ...
    Dim mySelectQuery7 As String = "SELECT '" & i & "' FROM moduli WHERE id='" & txtid.Text & "'"
                    Dim myConnection3 As New MySqlConnection(connStr)
                    Dim myCommand3 As New MySqlCommand(mySelectQuery7, myConnection3)
                   
                    If myConnection3.State = ConnectionState.Closed Then
                        myConnection3.Open()
                    End If
                    Dim myReader3 As MySqlDataReader
                    myReader3 = myCommand3.ExecuteReader()
                    
                    While myReader3.Read
                        
                       Perditaefficienza.Text = myReader3.Item(i) 
                        
                    End While
                   
                    myConnection3.Close()
                    
    
    next

  2. #2
    Utente di HTML.it L'avatar di Mychy
    Registrato dal
    Oct 2000
    Messaggi
    794
    L'indice di myReader3.Item è sempre 0
    prova così:
    codice:
    For i As Integer = 1 To 25
    ...
    Dim mySelectQuery7 As String = "SELECT '" & i & "' FROM moduli WHERE id='" & txtid.Text & "'"
                    Dim myConnection3 As New MySqlConnection(connStr)
                    Dim myCommand3 As New MySqlCommand(mySelectQuery7, myConnection3)
                   
                    If myConnection3.State = ConnectionState.Closed Then
                        myConnection3.Open()
                    End If
                    Dim myReader3 As MySqlDataReader
                    myReader3 = myCommand3.ExecuteReader()
                    
                    While myReader3.Read
                        
                       Perditaefficienza.Text = myReader3.Item(0) 
                        
                    End While
                   
                    myConnection3.Close()
                    
    
    next

  3. #3
    Utente di HTML.it L'avatar di lory38
    Registrato dal
    Dec 2010
    Messaggi
    214
    non mi funziona ho bisogno dei risultati che li prende dai dati.

  4. #4
    Utente di HTML.it L'avatar di Mychy
    Registrato dal
    Oct 2000
    Messaggi
    794
    L'errore è sempre quello?

  5. #5
    Utente di HTML.it L'avatar di lory38
    Registrato dal
    Dec 2010
    Messaggi
    214
    si, mi trovo solo i numeri da 1 a 25 e non li fa vedere i numeri che doveva prendere sul database e non li fa.

  6. #6
    Utente di HTML.it L'avatar di Mychy
    Registrato dal
    Oct 2000
    Messaggi
    794
    quindi l'errore è sempre:
    Errore: Indice oltre i limiti della matrice

  7. #7
    Utente di HTML.it L'avatar di lory38
    Registrato dal
    Dec 2010
    Messaggi
    214
    no, non mi segna errore ma i numeri quello che avevo scritto prima.

  8. #8
    Utente di HTML.it L'avatar di Mychy
    Registrato dal
    Oct 2000
    Messaggi
    794
    togli gli apici dalla query:
    "SELECT " & i & " FROM moduli WHERE id='" & txtid.Text & "'"

  9. #9
    Utente di HTML.it L'avatar di lory38
    Registrato dal
    Dec 2010
    Messaggi
    214
    ho provato quello che mi hai chiesto tu è lo stesso come prima.

  10. #10
    Utente di HTML.it L'avatar di lory38
    Registrato dal
    Dec 2010
    Messaggi
    214
    up

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.