RIAS
asked on
Correct code
Hello,
Is there a better way of writing this:
Public Function FindValue(ByVal tablename As String, ByVal StrCol1 As String, ByVal StrCol2 As String, ByVal StrValue As String)
'get max value in the column
MedicalSQL.OpenConnection( )
Dim SQLobj As New SqlCommand("al_FrmCol")
Dim StrReturnValue As Object = String.Empty
Try
SQLobj.Parameters.AddWithV alue("@tab leName", tablename)
SQLobj.Parameters.AddWithV alue("@Col umnName1", StrCol1)
SQLobj.Parameters.AddWithV alue("@Col umnName2", StrCol2)
SQLobj.Parameters.AddWithV alue("@Val ue", StrValue)
SQLobj.CommandType = CommandType.StoredProcedur e
SQLobj.Connection = MedicalSQL.GetConnection
If SQLobj.ExecuteScalar Is DBNull.Value = False Then
StrReturnValue = SQLobj.ExecuteScalar
End If
MedicalSQL.CloseConnection ()
Return StrReturnValue
Catch ex As Exception
MessageBox.Show(ex.ToStrin g)
End Try
End Function
Cheers
Is there a better way of writing this:
Public Function FindValue(ByVal tablename As String, ByVal StrCol1 As String, ByVal StrCol2 As String, ByVal StrValue As String)
'get max value in the column
MedicalSQL.OpenConnection(
Dim SQLobj As New SqlCommand("al_FrmCol")
Dim StrReturnValue As Object = String.Empty
Try
SQLobj.Parameters.AddWithV
SQLobj.Parameters.AddWithV
SQLobj.Parameters.AddWithV
SQLobj.Parameters.AddWithV
SQLobj.CommandType = CommandType.StoredProcedur
SQLobj.Connection = MedicalSQL.GetConnection
If SQLobj.ExecuteScalar Is DBNull.Value = False Then
StrReturnValue = SQLobj.ExecuteScalar
End If
MedicalSQL.CloseConnection
Return StrReturnValue
Catch ex As Exception
MessageBox.Show(ex.ToStrin
End Try
End Function
Cheers
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER