Problema con .dbf

29/09/2006 - 23:27 por Guillermo | Informe spam
Estoy intentando conectarme con una base de datos .dbf, pero no puedo ver los
datos el codigo es mas o menos así:

Dim Cont As New OLEDBConnection
Dim Da As New OleDbDataAdapter
Dim Cmd As New OleDbCommand
Dim Ds As New DataSet
Dim StrQuery As String

Cont.ConnectionString = ""

StrQuery = "SELECT * FROM 'E:\NVC\NVCITEM.DBF'"

Da.SelectCommand = Cmd
Da.SelectCommand.CommandText = StrQuery
Da.SelectCommand.CommandType = CommandType.Text
Da.SelectCommand.Connection = Cont
Try
Cont.Open()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Try
Da.SelectCommand.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Cont.Close()
Da.Fill(Ds, 0)
Me.DataGrid1.DataSource = Ds.Tables(0)
Quisiera saber cual es el problema y como puedo resolverlo.

Gracias
 

Leer las respuestas

#1 Jorge Serrano [MVP VB]
30/09/2006 - 10:33 | Informe spam
Hola Guillermo,

vamos por partes:

Lo primero que debes hacer es instalarte Microsoft OLE DB Provider for
Visual FoxPro 9.0
(http://www.microsoft.com/downloads/...x?FamilyIDáa87d8f-2d58-491f-a0fa-95a3289c5fd4&DisplayLang=en). Ocupa unos 2,5 Mb.

Una vez hecho esto, lo segundo, modificar tu código, en concreto la línea:
Cont.ConnectionString = "Provider=vfpoledb.1;Data Source=
'E:\NVC\';Collating Sequence=general;"


Pruébalo y me comentas que tal.

Un saludo.

Jorge Serrano Pérez
Microsoft MVP VB.NET
PortalVB.com
http://www.portalvb.com/
Blog de Jorge Serrano
http://geeks.ms/blogs/jorge/default.aspx


"Guillermo" wrote:

Estoy intentando conectarme con una base de datos .dbf, pero no puedo ver los
datos el codigo es mas o menos así:

Dim Cont As New OLEDBConnection
Dim Da As New OleDbDataAdapter
Dim Cmd As New OleDbCommand
Dim Ds As New DataSet
Dim StrQuery As String

Cont.ConnectionString = ""

StrQuery = "SELECT * FROM 'E:\NVC\NVCITEM.DBF'"

Da.SelectCommand = Cmd
Da.SelectCommand.CommandText = StrQuery
Da.SelectCommand.CommandType = CommandType.Text
Da.SelectCommand.Connection = Cont
Try
Cont.Open()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Try
Da.SelectCommand.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Cont.Close()
Da.Fill(Ds, 0)
Me.DataGrid1.DataSource = Ds.Tables(0)
Quisiera saber cual es el problema y como puedo resolverlo.

Gracias

Preguntas similares