Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TRANSFER DATA FROM SQL TO ACCESS

Status
Not open for further replies.

bertrandkis

Programmer
Jul 26, 2002
101
ZA

I WOULD LIKE TO TRANSFER DATA FROM SQL SERVER TO A TABLE IN ACCESS BUT IT DOES NOT SEEM TO WORK THIS IS HOW I DO IT:

Dim mySelectCommand As SqlCommand = New SqlCommand("select * from customers", SqlConnection1)

Dim mySqlDataAdapter As SqlDataAdapter = New SqlDataAdapter(mySelectCommand)
Dim sqlDs As DataSet = New DataSet()

Dim accCommand As OleDbCommand = New OleDbCommand("Select * from customers", OleDbConnection1)

Dim accAdapter As OleDbDataAdapter = New OleDbDataAdapter(accCommand)

Dim accDataSet As DataSet = New DataSet()
accAdapter.Fill(yDataSet)

mySqlDataAdapter.Fill(sqlDs)

'I MERGE THE SQLDATASET INTO THE ACCESS DATASET SO
'AS TO TRANFER DATA

accDataSet.Merge(sqlDs)
'TO TEST IF THE MERGE WORKED I DISPAY THE MERGED
' DATA IN A DATAGRID AND THE DATAGRID DOES SHOW
'THE DATA
DataGrid1.DataSource = accDataSet
'NOW I CALL THE UPDATE METOD OF THE DATA ADAPTER
'NO ERROR IS RETURNED BUT WHEN I OPEN THE TABLE IN ACCESS NO DATA IS FOUND IN TABLE. WHAT IS WRONG? PLEASE HELP.
accAdapter.Update(accDataSet)

REGARDS.
 
Hi !

Calling OleDbDataAdapter.Update causes the update command (OleDbDataAdapter.UpdateCommand) to be run.
As you did not define an update command, nothing is run.
So nothing is updated.

If you work with visual studio, add an OleDbAdapter to a form using the toolbox. Follow the steps of the wizard, then go see what code it wrote for you. That is the way you have to specify update commands (I mean like the wizard does : he's a good teacher).

Otherwise, search the help (sdk) for update commands and parameters ('cause they all require parameters).

Keywords 'OleDbDataAdapter', 'OleDbParameter'

Cheers

Grunt


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top