J
Jamal
Hi,
I am trying to import a FoxPro 2.6 DBF table into SQL table using the
following connection string:
Dim ds As DataSet
Dim cDbfName AS String = "mydbf"
Dim sql As String = "SELECT * FROM " + cDbfName
ds = GetDataTable(str_path, sql)
Public Function GetDataTable(ByVal str_path As String, ByVal sql As String)
As DataSet
Dim ds As New DataSet
Dim da As New OdbcDataAdapter()
Dim con As New OdbcConnection("Driver={Microsoft dBASE Driver
(*.dbf)};DriverID=277;Dbq=" + str_path)
Using con
Dim adapter As New OdbcDataAdapter(sql, con)
' Open the connection and fill the DataSet.
Try
con.Open()
adapter.Fill(ds) ' debug breakpoint here to view ds
contents.
Catch ex As Exception
Throw New ApplicationException("Exception Occured: " +
ex.Message)
End Try
End Using
Return ds
End Function
When I debug the 'ds' variable which refers to the dataset, all the columns
read appear fine in the grid, however some columns are blank even though
they have values in the read DBF file.
In particular a column named EMAIL which 60 chacacters long. I changed the
column name to EMAIL1, however, it did not make a difference.
Anyone has a clue on why this occurring and how to correct it?
Using VS 2008 Sp1, SQL Server 2008 sp1.
Thanks,
James
I am trying to import a FoxPro 2.6 DBF table into SQL table using the
following connection string:
Dim ds As DataSet
Dim cDbfName AS String = "mydbf"
Dim sql As String = "SELECT * FROM " + cDbfName
ds = GetDataTable(str_path, sql)
Public Function GetDataTable(ByVal str_path As String, ByVal sql As String)
As DataSet
Dim ds As New DataSet
Dim da As New OdbcDataAdapter()
Dim con As New OdbcConnection("Driver={Microsoft dBASE Driver
(*.dbf)};DriverID=277;Dbq=" + str_path)
Using con
Dim adapter As New OdbcDataAdapter(sql, con)
' Open the connection and fill the DataSet.
Try
con.Open()
adapter.Fill(ds) ' debug breakpoint here to view ds
contents.
Catch ex As Exception
Throw New ApplicationException("Exception Occured: " +
ex.Message)
End Try
End Using
Return ds
End Function
When I debug the 'ds' variable which refers to the dataset, all the columns
read appear fine in the grid, however some columns are blank even though
they have values in the read DBF file.
In particular a column named EMAIL which 60 chacacters long. I changed the
column name to EMAIL1, however, it did not make a difference.
Anyone has a clue on why this occurring and how to correct it?
Using VS 2008 Sp1, SQL Server 2008 sp1.
Thanks,
James