Using Dataset's

M

Martin

Hi, I've got a scenario where I have two different data sources, one is an
SQL server and the other is a Foxpro DBF table. What I'm trying to do is
take data from the SQL server and place it into the DBF table this is the
code I have so far.

Code:
'======= SQL Connection ======
Dim strConn As String = "user id=*******;password=*******;data
source=***.***.***.***;persist security info=False;initial catalog=*******"
Dim sqlCon As New SqlConnection(strConn)
Dim objDR As SqlDataReader
Dim objDA As New SqlDataAdapter
Dim objDS As New DataSet
'==============================
Try
'Open Connection
sqlCon.Open()
'Define SQL command
objDA.SelectCommand = New SqlCommand("contacts", sqlCon)
'Execute SQL command
objDA.Fill(objDS, "contacts")

Catch strError As Exception
MessageBox.Show(strError.ToString)
Finally
'Close and Dispose Connection
sqlCon.Close()
sqlCon.Dispose()
End Try
'==============================

'Foxpro ODBC Connection
Dim strFoxProConn As String = "Driver={Microsoft Visual FoxPro
Driver};SourceType=DBF;SourceDB=c:\;Exclusive=No"
Dim OdbcConn As New OdbcConnection(strFoxProConn)
'==============================

I have created a SQL connection to the SQL server and returned the data to a
dataset. I have then created a ODBC connection to the DBF table, this is
where I am now stuck and not too sure what to do. My knowledge of VB.NET is
not great that's why I'm posting on here with the hope that somebody can
point me in the right direction of what to do next.

Thanks in Advance.
 
E

EricJ

ill fill in the first part ;)
'==============================

'Foxpro ODBC Connection
Dim strFoxProConn As String = "Driver={Microsoft Visual FoxPro
Driver};SourceType=DBF;SourceDB=c:\;Exclusive=No"
Dim OdbcConn As New OdbcConnection(strFoxProConn)
'==============================
dim r as datarow
for each r in objDS.tables(0).rows
'insert the value of r(0) in your dbf file (row per row)
next

hope it helps

eric
 

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

Top