error: Data source is an invalid type

D

Dan

Hi,

I'm learning asp.net 2.0 and i get this error:
"Data source is an invalid type. It must be either an IListSource,
IEnumerable, or IDataSource"

My code:
Dim a As GridView
Dim oConnection As OleDbConnection
oConnection = New OleDbConnection()
Dim comd As OleDbCommand
Dim sql As String
Dim a as GridView
Dim sConnectionString As String
sConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
= c\test.mdb"
oConnection.ConnectionString = sConnectionString
oConnection.Open()
sql = "SELECT ...;"

comd = New OleDbCommand(sql, oConnection)
a = New GridView
a.DataSource = comd
a.DataBind()
oConnection.Close()

Thanks
Dan
 
P

PeterKellner

Hi,

I'm learning asp.net 2.0 and i get this error:
"Data source is an invalid type. It must be either an IListSource,
IEnumerable, or IDataSource"

My code:
Dim a As GridView
Dim oConnection As OleDbConnection
oConnection = New OleDbConnection()
Dim comd As OleDbCommand
Dim sql As String
Dim a as GridView
Dim sConnectionString As String
sConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source
= c\test.mdb"
oConnection.ConnectionString = sConnectionString
oConnection.Open()
sql = "SELECT ...;"

comd = New OleDbCommand(sql, oConnection)
a = New GridView
a.DataSource = comd
a.DataBind()
oConnection.Close()

Thanks
Dan

I think you are wanting to make your datasource a dataset, not a
OleDbCommand. You need to create a dataset, the fill it using a
dataadapter.
Peter Kellner
http://peterkellner.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top