Use of SqlDataAdapter in .NET

xiaoxiao2021-03-06  71

In general, use SqlDataAdapter to connect with DataSet, use SqlDataAdapter to get the data in the database, populate it into the DataSet. First, in order to execute the SELECT query from the SQL database, you need to create a SQLConnection object that connects to the database by connecting the string, and then constructs a SQLDataAdapter object that contains query statements. In order to fill to the DataSet object with the query return result, you need to call the SqlDataAdapter's Fill method. Note: SqlConnection Sconn = "Server = local; Database = Pubs; Trusted_Connection = YES;" SqlDataAdapter SDA = SqlDataAdapter ("Select * from sales", sconn; dataset ds = new dataset (); sda. Fill (DS, "Sales"); sda.dispose (); this, assigns the data table Sales in the public to the DS. Finally, the connection of the SDA with the database is broken.

转载请注明原文地址:https://www.9cbs.com/read-88046.html

New Post(0)