本文介绍了当我运行程序并选择ComboBox并单击OK按钮时gridview不会显示任何内容。只有两个Dsc显示在gridview中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库表:付费和非项目和成员。

付费和会员,Dsc字段很常见。

我有两种形式,每种形式都是表Nproject当您单击确定按钮将数据加载到gridview上的表格时,ComboBox Dsc字段显示。



但现在当我运行程序并选择ComboBox并单击OK按钮gridview不显示任何内容。只有两个Dsc显示在gridview中。



我使用sql serever 2008作为数据库。在Member表中Dsc字段Type是nvarchar(254)。当运行程序时,只在dbgrid中显示两个Dsc(بدونپروژه - گلمان),其他Dsc不显示在dbgrid中。



-----





Proge.text是两种形式的组合框



پروژه144واحدی**不要在dbrid中显示这个dsc

粉丝156واحدی**不要在dbrid中显示这个dsc

پروژه240واحدي

بدونپروژه

گلمان



----------------



CodeSource Ds = new CodeSource();

Grd.DataSource = Ds.LoadGrids(选择*来自会员,其中Dsc ='+ Proge.Text +') ;



----------



我的班级代码名称:CodeSource



public BindingSource LoadGrids(string SqlStatement)

{

SqlDataAdapter sda = new SqlDataAdapter(SqlStatement,connectionString) ;

D. ataTable dTable = new DataTable();

sda.Fill(dTable);

BindingSource bSource = new BindingSource();

bSource.DataSource = dTable;

sda.Dispose();

dTable.Dispose();

返回bSource;

Database tables: Pay and Nproject and Member.
The Pay and Member, Dsc field is common.
I have two forms, in each form is a table Nproject ComboBox Dsc field when you click the OK button to load the data into the table on gridview is displayed.

But now when I run the program and choose the ComboBox and click OK button gridview does not display anything.Just Two Dsc show in gridview.

I Use sql serever 2008 for database. In Member table Dsc field Type is nvarchar(254). when run a program just display two Dsc(بدون پروژه - گلمان) in dbgrid and other Dsc don't display in dbgrid.

-----


Proge.text is combobox in two forms

پروژه 144 واحدی ** Dn't show this dsc in dbrid
پروژه 156 واحدی ** Dn't show this dsc in dbrid
پروژه 240 واحدي
بدون پروژه
گلمان

----------------

CodeSource Ds = new CodeSource();
Grd.DataSource = Ds.LoadGrids("Select * From Members where Dsc = '" + Proge.Text + "' ");

----------

code in my class Name's : CodeSource

public BindingSource LoadGrids(string SqlStatement)
{
SqlDataAdapter sda = new SqlDataAdapter(SqlStatement, connectionString);
DataTable dTable = new DataTable();
sda.Fill(dTable);
BindingSource bSource = new BindingSource();
bSource.DataSource = dTable;
sda.Dispose();
dTable.Dispose();
return bSource;




--------------


--------------

推荐答案

"Select * From Members where Dsc = '" + Proge.Text + "' "





在字符串参数周围有引号(')。如果您使用的是MS SQL,那就错了。这是MySQL的语法。使用SQL Management Studio测试您的查询。



has quotes (') around the string parameter. If you're using MS SQL this is wrong. This is syntax for MySQL. Use SQL Management Studio to test your query.


这篇关于当我运行程序并选择ComboBox并单击OK按钮时gridview不会显示任何内容。只有两个Dsc显示在gridview中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 14:00