Advertisement

08.25.2004 at 07:03PM PDT, ID: 21107698
[x]
Attachment Details

How do I perform a boolean test to see if a value is or is not in a DB?

Asked by travishaberman in Miscellaneous Web Development

Hello all,

I know this is easier than it looks...

I used the ASP.NET WebMatrix's "Select Data Method" to buid the following code.

============================================================================
 Function DoesAccountExist(ByVal userName As String) As System.Data.DataSet
        Dim connectionString As String = "server='(local)'; trusted_connection=true; database='Clients'"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
       
        Dim queryString As String = "SELECT [Account].[UserName] FROM [Account] WHERE ([Account].[UserName] = @UserNam"& _
"e)"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection
       
        Dim dbParam_userName As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
        dbParam_userName.ParameterName = "@UserName"
        dbParam_userName.Value = userName
        dbParam_userName.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_userName)
       
        Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
        dataAdapter.SelectCommand = dbCommand
        Dim dataSet As System.Data.DataSet = New System.Data.DataSet
        dataAdapter.Fill(dataSet)
       
        Return dataSet
    End Function

==============================================================================

My problem is. I want this to be a boolean function and simply return a TRUE/FALSE indicating wheter a value I pass it is or is NOT in the dataSet.

Any thoughts?

-TH
Start Free Trial
[+][-]08.25.2004 at 08:45PM PDT, ID: 11899381

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Miscellaneous Web Development
Sign Up Now!
Solution Provided By: ryancys
Participating Experts: 2
Solution Grade: B
 
 
[+][-]08.26.2004 at 04:40AM PDT, ID: 11901485

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.26.2004 at 01:07PM PDT, ID: 11906895

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.27.2004 at 12:48PM PDT, ID: 11916989

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32