Public Function GetColumnValue:
Public Function GetColumnValue:
This method is used to get the specified column value
It accepts 5 arguments namely, TableName, FieldName, KeyName, KeyValue and datatype
TableName – Name of the table
FieldName – Name of the Field
KeyName – Name of the Column Name used to filter the table.
Keyvalue – value used in the filter
Datatype – Datatype of the keyname.
Public Function GetColumnValue(ByVal TableName As String, ByVal FieldName As String, ByVal KeyName As String, ByVal KeyValue As String, ByVal datatype As String)
Dim result As String
Try
If datatype = "C" Then KeyValue = "'" & KeyValue & "'"
str_qry = "select " & FieldName & " as Colvalue from " & TableName & " WHERE " & KeyName & "=" & KeyValue
cmd = New SqlCommand(str_qry, con)
con.Open()
result = cmd.ExecuteScalar()
Return result
Catch ex As Exception
MsgBox(ex.Message.ToString)
Finally
con.Close()
End Try
End Function
<< Home