Thursday, March 22, 2012

OleDb FoxPro Problems!

Hi,

I was using the code below to pull up records from an access database which worked fine, but I now want to do the same to a foxpro 7 database.

It connects to the foxpro dbase but after stepping through the code I found it crashes at

"dgPrevious.DataSource = cmdSelect.ExecuteReader"

the error is "Object reference not set to an instance of an object."

Dim con As OleDb.OleDbConnection
Dim cmdSelect As OleDb.OleDbCommand

Call OpenConnection() ' Own procedure

sqlquery = "SELECT Datereq, NetLogin, Title, Status, RequestId FROM " & tbname

cmdSelect = New OleDb.OleDbCommand(sqlquery, con)

dgPrevious.DataSource = cmdSelect.ExecuteReader

dgPrevious.DataBind()

Thanks

ChrisBy experience I find that if there is a problem with db connection it fails after code for connection but when you apply it.
Can you post the code for Call OpenConnection() ?
I suspect there is a problem here (perhaps).

0 comments:

Post a Comment