我是 C# 程序员。目前,我正在尝试在 datagrid-viewer 的 sql 数据中添加 5 列中的 3 列(fileId、filePath、authorName、fileContent、DateSend);fileId 和 fileContent 列是隐藏的。非常感谢!
con = new SqlConnection("Data Source=LEO-PC\\SQLEXPRESS;Initial Catalog = datashare;Integrated Security = True");
cmd = new SqlCommand("select * from maintable", con);
con.Open();
SqlDataReader sqlRead;
try
{
sqlRead = cmd.ExecuteReader();
while (sqlRead.Read())
{
//Adding to datagrid
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}