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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataReader Question 1

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
Can someone tell me whats wrong???


Dim dbcn As OleDb.OleDbConnection = New OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("DB.mdb;"))

Dim DBComm = New OleDb.OleDbCommand("SELECT Field FROM Table", dbcn)

Dim MyReader As OleDb.OleDbDataReader

dbcn.Open()

This is where i have problems

MyReader = DBComm. the only choice is GetType..

I know it should be ExecuteReader..

What did i do wrong??

Forgive me I am still new to .Net

Thanks

 
Instead of this line:

Dim DBComm = New OleDb.OleDbCommand("SELECT Field FROM Table", dbcn)

Try this line:
Dim DBComm AS New OleDb.OleDbCommand("SELECT Field FROM Table", dbcn)

Without the "AS" in the declaration, it treats DBComm as a generic object, so the functions related with the OleDbCommand are not shown.

HTH!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top