ciao a tutti...
in una classe faccio una semplice query al mio database installato in un pc remoto
la connessione è ok e testata...
ma l'errore che mi riporta l' executereader proprio non riesco a capirlo
Errore di sintassi su parola chiave "User" :berto:
vi posto la funzione...
e un esempio di passaggio ByVal alla funzione
Function SelectUserPsw(ByVal Username As String, ByVal Password As String) As Boolean
Return LeggiDati("select * from User WHERE Username = '" & Username & "' and Password = '" & Password & "' ")
End Function
Public Function LeggiDati(ByVal sql As String) As Boolean
Dim Command As SqlClient.SqlCommand
Dim DataReader As SqlClient.SqlDataReader
Dim ret As Boolean = False
Dim stringconnection As String = "Data Source=SRV\SQLEXPRESS;Initial Catalog=myinvent;User ID=test;Password=invent"
Dim cnn As New SqlClient.SqlConnection
cnn.ConnectionString = stringconnection
cnn.Open()
Command = New SqlClient.SqlCommand
Command.CommandText = sql
Command.CommandType = CommandType.Text
Command.Connection = cnn
DataReader = Command.ExecuteReader
If DataReader.Read Then
mUserid = DataReader("User_id").ToString()
mNome = DataReader("Nome").ToString()
mCognome = DataReader("Cognome").ToString()
mGrp_Aut_id = DataReader("Grp_Aut_id").ToString()
Password = DataReader("Password").ToString()
Username = DataReader("Username").ToString()
ret = True
End If
DataReader.Close()
DataReader.Dispose()
Command.Dispose()
Return ret
End Function