Good morning everyone.
This is not a problem or a error, just a small help for code optimization.
In all of my apps, when I need to get only one value for a database (Sql compact for example or other) I use allways the same code.
I think is a big and slow code, and I'm sure that it's posisble optimize that.
I use this for example:
How can I optimize this code, when I know the result its only one row?? For examplo check if the password is correct for a specific user.
Thank you
This is not a problem or a error, just a small help for code optimization.
In all of my apps, when I need to get only one value for a database (Sql compact for example or other) I use allways the same code.
I think is a big and slow code, and I'm sure that it's posisble optimize that.
I use this for example:
Code:
Public Function CalculaDataFecho() As Date
Dim ConexaoBD As SqlConnection
Dim DsDados As DataSet
Dim Dt As DataTable
Dim Row As DataRow
Dim DataFecho As Date
Dim sqlString As String = "SELECT fecho FROM dbo.fecho"
ConexaoBD = New SqlConnection(connString)
Dim AdaptadorDados As SqlDataAdapter = New SqlDataAdapter(sqlString, ConexaoBD)
DsDados = New DataSet()
AdaptadorDados.Fill(DsDados, "fecho")
Dt = DsDados.Tables("fecho")
For Each Row In Dt.Rows
DataFecho = Row(0)
Next
Return DataFecho
End FunctionThank you