How to: dBase as Datasource

  • Thread starter Thread starter JeffP@Laptop
  • Start date Start date
J

JeffP@Laptop

datagrid1 has a single column contact

I'm getting an invalid datasource at...
Me.DataGrid1.DataSource = cmd

I don't want to use the methods here, I usually use SQLHelper
psuedo code: dim ds as new dataset = execute(.......

I just want to get my single colum populated.....

I'll work on more advanced stuff later....

'snipit...
Dim cmd As New OleDb.OleDbCommand
Dim cnn As OleDb.OleDbConnection
cnn = New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"C:\Apps\R2M\Database;Extended Properties=DBASE
IV;")
cmd.CommandText = "select c1.* ,c2.* from c1 ,c2 where c1.accno
= c2.accno"
cmd.CommandType = CommandType.Text
cmd.Connection = cnn
cnn.Open()
'I chose this because it's there, perhaps another Excute Type
would be better.
cmd.ExecuteNonQuery()
cnn.Close()

'the following line casuses the noted error
Me.DataGrid1.DataSource = cmd
Me.DataGrid1.DataBind()

cnn.Dispose()
TIA

JeffP....
 
I assume an ordinary access db will fail as well.
I say so since the connection is terminated
Make it a real connectionstring in web.config
 
To be clear, a datagrid is an obsolete control in vs2005.
but that's not the point for now, i recommend the sqldatasource being placed
on the form and let it build a conn string for you.
The grid should be connected to the sqldatasource.. SO, NO CODE.
 
Edwin, I'm very confused by your reply.

My datasource is comprised of files not an SQL database.

I will eventually place my conn string in the web.config as well as all of my
data access into a common.vb file similar to SQLHelper.

But for now I just want to connect to my database and read a single column,
"Hello World" style.

Perhaps this will help. my database files are dBase 4 or 6 files that reside in
the path;

C:\Apps\R2M\Database

Data file c1.dbf
Memo Blob file c1.dbt
Index file c1.mdx

This is not an MS Access database.

TIA

JeffP.....
 
If you want i can write a VS2005 (!) example with the gridview?

I'm sure it works but i have to test.
Do NOT try to write a connectionstring manually, the sqlsdatasource cn do
that for you.
My collegue is also not use to that, let the designer help you, not code
involved.

Give me a call if you need a dbf example.
Would be nice if i had your dbf to use.

sqldatasource is NOT directly related to sqlserver.
A wrong name imo.
Forget the access datasource, this is a wweird breed imo.
Evt. mail.
 

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

Back
Top