返回项目列表:
List<string> data = new List<string>();
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
string strCommandtext = "SELECT CONCAT([name],'_',[Number]) FROM [newTable]";
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(strCommandtext, connection);
DataSet ds = new DataSet();
sqlDataAdapter.Fill(ds);
foreach (DataRow drRow in ds.Tables[0].Rows)
{
controllerData.Add(drRow[0].ToString());
}
}
string demo = JsonConvert.SerializeObject(controllerData);
return demo;
插入文档db / cosmos db
await client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("databaseID", "collectionID"), demo);
但是会引发错误:
{“对象引用未设置为对象的实例。”}