DataAdapter & SQLClient

  • Thread starter Thread starter Bonato Pierantonio
  • Start date Start date
B

Bonato Pierantonio

Hi All,
I have a problem.... I want to update a table in MS Sql Server using the
class SQLClient DataAdapter.
I can set the property UpdateCommand of my DA but I cannot find the method
UPDATE ( I use VB.NET)

I hope to be clear....

Thanks for your help
Bonato Pierantonio
 
I can give you two choices:

1. Create either a SQL statement for update or a stored procedure and link
to the UpdateCommand property of the DataAdapter.

2. Use a CommandBuilder to create the UPDATE command off of your SELECT
command.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Don't forget the Insert and Delete commands. (The CommandBuilder will take
care of them for you.)

But if the problem is just that the Update method doesn't show in
autocomplete then simply type it in and see if it compiles.

Here's some C# code I use to update a table (given a DataTable whose name
matches the source tablename):

System.Data.SqlClient.SqlDataAdapter dba = new
System.Data.SqlClient.SqlDataAdapter
(
"SELECT * FROM " + Subject.TableName
,
this.dbc.ConnectionString
) ;

System.Data.SqlClient.SqlCommandBuilder cb = new
System.Data.SqlClient.SqlCommandBuilder ( dba ) ;

dba.Update ( Subject ) ;
 
Hi,

If you have imported proper namespaces, as you are setting the UpdateCommand
property of the DA. Refresh the environment and you will definitely will be
able to use the Update method in right way.

Regards,
 
Back
Top