ASP.NET and SELECT queries?

Netnoobie

Well-known member
Joined
Feb 6, 2003
Messages
94
Location
Philadelphia
Hi! I cant seem to find a way in ASP.NET to fire off a SELECT statement and have be able to get the returned value. Do I need to use ADO.NET to simplet do a SELECT where only one value is retuened? So far my .NET database experience has been in doing UPDATES/INSERTS and SELECT queries for DopDownLists. So Im really not sure how to get a query to return results.

Many Thanks!
 
Can you give more details or put your code here? Which database are you using?
You can use a datareader to get query results.
 
Right sorry.

Im using MySQL and I seem to have problems in using OLE DB to execute a data reader. Im currently looking into mySQLs support of OLE DB, but Im not finding anything. Is it possible to execute a data reader from ODBC?

Thanks!
 
I actually answered my own question.

you dont have to use OLE DB to use the data reader. ODBC works just as well.

Code:
Dim objConnection As OdbcConnection
    objConnection = New OdbcConnection("DSN=RhMySQL")
    objConnection.Open()   open the connection

    Dim objCommand As OdbcCommand
    objCommand = New OdbcCommand(strSQL, objConnection)

    Dim objDataReader As OdbcDataReader
    objDataReader = objCommand.ExecuteReader

    While objDataReader.Read()
      strTest = objDataReader("Type")
    End While

   objDataReader.Close()

    objConnection.Close()
 
Back
Top