Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    errore nella query, ma la query è banale...

    ciao a tutti...allora ho questo assurdo problema.
    vi posto il code

    codice:
    Dim sql As New MySqlCommand("Select * from utenti WHERE username = '" & uname.Text & "' AND pass = '" & pswd.Text & "' ", myConn)
            Dim rs As MySqlDataReader
            rs = sql.ExecuteReader()
            If rs.Read = "True" Then
                Dim nome As String
                nome = rs("username")
                nomeutente.text = nome
                Dim sql2 As MySqlCommand
                sql2 = New MySqlCommand("SELECT * FROM database WHERE id_database = " & rs("id_database") & "", myConn)
                'Response.Write(aaa)
                Dim rs2 As MySqlDataReader
                rs.Close()
                rs2 = sql2.ExecuteReader()
                Session("id_utente") = rs("id_utente")
                Session("status") = rs("status")
                Session("id_database") = rs("id_database")
                If rs2.Read = "True" Then
                    Session("port_db") = rs2("port_db")
    il primo comando sql lo esegue benissimo. al secondo ho questo errore e non so proprio cosa fare..

    #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database WHERE id_database = 1' at line 1
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: MySql.Data.MySqlClient.MySqlException: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database WHERE id_database = 1' at line 1

    Source Error:


    Line 26: Dim rs2 As MySqlDataReader
    Line 27: rs.Close()
    Line 28: rs2 = sql2.ExecuteReader()
    Line 29: Session("id_utente") = rs("id_utente")
    Line 30: Session("status") = rs("status")
    dove sta l'errore ?
    io non riesco proprio a trovarlo...
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  2. #2
    ad occhio sembrerebbe qui
    codice:
    sql2 = New MySqlCommand("SELECT * FROM database WHERE id_database = " & rs("id_database") & "", myConn)
                'Response.Write(aaa)
                Dim rs2 As MySqlDataReader
                rs.Close()
                rs2 = sql2.ExecuteReader()
    non puoi chiudere rs prima della seconda query, a meno che tu non metta il valore di rs("id_database") in una variabile e poi usi quella
    "...non è detto che sia tardi se non guardi che ora è..."

  3. #3
    giusto
    ma se metto quel valore in una variabile, kiudo rs e poi apro rs2
    ho sempre lo stesso errore
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  4. #4
    prova

    sql2 = New MySqlCommand("SELECT * FROM [database] WHERE id_database = " & rs("id_database") & "", myConn)
    "...non è detto che sia tardi se non guardi che ora è..."

  5. #5
    sempre uguale....
    è incredibile!!!!
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  6. #6
    non puoi fare una prova cambiando il nome al db? così, tanto per essere sicuri che sia quello...
    "...non è detto che sia tardi se non guardi che ora è..."

  7. #7
    provo e ti dico
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

  8. #8
    in effetti era proprio quello....
    ci potevo stare anni a provare e riprovare....

    certo che potevano fare in modo che certi nomi nn vengano usati ....

    grazie mille
    -------------------------
    ..::`DrUmM\n0`::..
    www.jonathandomenici.com

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.