Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't get work simple sql select
Message
 
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01389064
Message ID:
01389094
Vues:
33
BTW, you can also use ExecuteScalar instead.

>It isn't ExecuteNonQuery() you want, is it? I thought that was for updates.
>
>>Hi,
>>My question probably funny.. but .. I try to ask
>>
>>I have a code
>>
>>        Dim lnAccountFound As Integer = 0
>>        loConnection = New SqlConnection(lcConnectionString)
>>        Try
>>            loCommand = New SqlCommand("SELECT id FROM Clients WHERE (mandator = @lcMandant) AND (login = @lcLogin) AND (password = @lcPassword)")
>>            loParameter1 = New SqlParameter("@lcLogin", Data.SqlDbType.VarChar, 12)
>>            loParameter1.Value = tcLogin
>>            loCommand.Parameters.Add(loParameter1)
>>            loParameter2 = New SqlParameter("@lcPassword", Data.SqlDbType.VarChar, 12)
>>            loParameter2.Value = tcPassword
>>            loCommand.Parameters.Add(loParameter2)
>>            loParameter3 = New SqlParameter("@lcMandant", Data.SqlDbType.VarChar, 50)
>>            loParameter3.Value = tcMandant
>>            loCommand.Parameters.Add(loParameter3)
>>            loCommand.Connection = loConnection
>>            loConnection.Open()
>>            lnAccountFound = loCommand.ExecuteNonQuery()
>>        Catch ex As Exception
>>        Finally
>>            If loConnection.State = Data.ConnectionState.Open Then
>>                loConnection.Close()
>>            End If
>>        End Try
>>
>>
>>The tcLogin, tcPassword, tcMandant - are String variables. the SQL Server columns has type varchar(12) and varchar(5).
>>
>>ExecuteNonQuery() returns -1
>>
>>When I create a Query in the VS.NET Server explorer - I have 1 record affected.
>>What do I wrong?
>>
>>Thanks
>>Denis
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform