Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!

Status
Not open for further replies.

coily

Technical User
Jan 26, 2005
25
GB
I a sql query that I need to retrieve the values returned in order to perform functions on. I cannot find how to reference these to put them into variables. The query is as follows.
Code:
Function loginQuery(ByVal username As String, ByVal password As String) As System.Data.DataSet
        Dim connectionString As String = "server='**************'; user id='************'; password='***********'; database='*********'"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

        Dim queryString As String = "SELECT [zoo_users].[username], [zoo_users].[password] FROM [zoo_users] WHERE (([z"& _
"oo_users].[username] = @username) AND ([zoo_users].[password] = @password))"
        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 dbParam_password As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
        dbParam_password.ParameterName = "@password"
        dbParam_password.Value = password
        dbParam_password.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_password)

        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

I think this should be so easy I just can't work out how I retrieve the username and password from the database into my own variables.

Any help is greatly recieved
 
You can set up additional parameters that will act as return parameters and set the direction of them. e.g
Code:
MyParameter.Direction = ParameterDirection.ReturnValue

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Sorry to be dim but what exactly do i need to add and where in my function.

Thanks for the reply but I just don't have that much understanding of .net to know what to do with your example.
 
Check out the following MSDN article that explains how to use return parameters (hint - it was the first reult returned from google when searching for "ParameterDirection.ReturnValue"):


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
(hint - it was the first reult returned from google when searching for "ParameterDirection.ReturnValue"):
Yeah I know!

I had searched for this answer before posting here but all the information I found made no sense.

Thanks anyway

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top