返回空数据

时间:2012-03-11 18:32:56

标签: c# winforms sql-server-2005

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 = "اذن_قيد";

当我使用此代码时,它返回null数据 但是当我在sql server“返回数据”中使用此命令时

1 个答案:

答案 0 :(得分:0)

我不认为上面的代码有任何错误。

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

其次,由于您在sql server查询中使用了某种语言结合,因此请确保ASP.NET重新认识查询并将其发送到适当的合并中的sql server。

希望这有帮助。

相关问题