返回空数据

本文关键字:数据 返回 | 更新日期: 2023-09-27 18:27:28

SqlConnection con = new SqlConnection("Data Source=MOSTAFA;Initial Catalog=mohasba;Integrated Security=True");
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = con.CreateCommand();
da.SelectCommand.CommandText = "select sum(مدين) AS مدين,sum (دائن) AS دائن  from  اذن_قيد  where اسم_البيان='" + comboBox1.SelectedIndex + "'";
da.Fill(ds, "اذن_قيد");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "اذن_قيد";

当我使用此代码时,它返回空数据但是当我在sql服务器"返回数据"中使用此命令时

返回空数据

我认为

上面的代码没有任何错误。

您可以尝试的是,首先确保您使用的连接字符串可以访问数据库。

其次,由于您在 sql 服务器查询中使用了某种语言协同,因此请确保 ASP.NET 重新协调查询并将其发送到适当的协同中的 sql 服务器。

希望这有帮助。