sql - Execute query using C# -
i trying execute sql code, connected directly database, don't know how execute query.
sqlconnection connect = new sqlconnection("database"); sqlconnection myconnection = connect; connect.open(); sqldataadapter adptador = new sqldataadapter(@"query", connect); datatable tabela = new datatable(); adptador.fill(table); clientcontext.web.lists.getbytitle("title"); clientcontext.executequery(); list list = clientcontext.web.lists.getbytitle("listname"); clientcontext.load(list); listitemcreationinformation listitemcreationinformation = new listitemcreationinformation(); listitem item = list.additem(listitemcreationinformation); foreach (datarow row in tabela.rows) { item["lastmodifiedby"] = row["lastmodifiedby"].tostring(); item.update(); cm = new sqlcommand("sql command"); **execute cm** clientcontext.executequery(); }
sqlcommand has executereader, executing command , returning dataset, executescalar returning single value of primitive type (int, string, etc.), or executenonquery returning nothing. can pass command sqldataadapter, , use populate datatable object.
please google sqlcommand , find lots of examples.
Comments
Post a Comment