本文介绍了从MS SQL到datagrid的结论是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我需要连接 tring saveStaff =选择roba为'Naziv artikla',SUM(施放(kolicina as float))作为'Količina'来自(选择roba,kolicina来自mp_racun_roba联盟所有选择roba,kolicina来自mp_faktura_roba)as alltables group by roba; 要清空数据网格 字符串工作但添加新列...不在我的实体栏中 我错了什么? 我尝试了什么: private void trenutne_zalihe2() { using(SqlConnection openCon = new SqlConnection(cs)) { string saveStaff =选择roba作为'Naziv artikla',SUM(演员(kolicina as float))作为'Količina'从(选择roba,kolicina来自mp_racun_roba union all select roba,kolicina来自mp_faktura_roba)作为alltables group by roba; 使用(SqlDataAdapter querySaveStaff = new SqlDataAdapter(saveStaff,cs)) { DataTable dt = new DataTable(); querySaveStaff.Fill(dt); trenutnazalihadataGridView.DataSource = dt; trenutnazalihadataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; trenutnazalihadataGridView.Columns [naziv_artikla] .FillWeight = 571; trenutnazalihadataGridView.Columns [kolicina] .FillWeight = 200; trenutnazalihadataGridView.Update(); trenutnazalihadataGridView.Refresh(); } } } 解决方案 I need to conect tring saveStaff = "Select roba as 'Naziv artikla', SUM (cast(kolicina as float)) as 'Količina' from (select roba, kolicina from mp_racun_roba union all select roba, kolicina from mp_faktura_roba) as alltables group by roba";To Empty datagridString work but add new column...not in my actualy columnWhat I wrong?What I have tried:private void trenutne_zalihe2() { using (SqlConnection openCon = new SqlConnection(cs)) { string saveStaff = "Select roba as 'Naziv artikla', SUM (cast(kolicina as float)) as 'Količina' from (select roba, kolicina from mp_racun_roba union all select roba, kolicina from mp_faktura_roba) as alltables group by roba"; using (SqlDataAdapter querySaveStaff = new SqlDataAdapter(saveStaff, cs)) { DataTable dt = new DataTable(); querySaveStaff.Fill(dt); trenutnazalihadataGridView.DataSource = dt; trenutnazalihadataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; trenutnazalihadataGridView.Columns["naziv_artikla"].FillWeight = 571; trenutnazalihadataGridView.Columns["kolicina"].FillWeight = 200; trenutnazalihadataGridView.Update(); trenutnazalihadataGridView.Refresh(); } } } 解决方案 这篇关于从MS SQL到datagrid的结论是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 14:38