Duwamish数据存取问题(50分)

  • 主题发起人 主题发起人 necyhk
  • 开始时间 开始时间
N

necyhk

Unregistered / Unconfirmed
GUEST, unregistred user!
我模仿Duwamish写了个取数据的程序,自己写了个数据集类,可以最后取不到数
据,请各位指点下
表结构
表名:BD_DESC
Type varchar 10 0
SubType varchar 10 0
Description varchar 30 0
CValues varchar 50 1
Parent varchar 50 1

//BD_Desc.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Runtime.Serialization;
namespace WindowsApplication3
{
/// <summary>
/// BD_Desc 的摘要说明。
/// </summary>
///
[System.ComponentModel.DesignerCategory("Code")]
[SerializableAttribute]
public class BD_Desc : DataSet
{
public const String BD_DESC_TABLE = "BD_DESC";
public const String TYPE_FIELD = "Type";
public const String SUBTYPE_FIELD = "SubType";
public const String DESCRIPTION_FIELD = "Description";
public const String CVALUES_FIELD = "CValues";
public const String PARENT_FIELD = "Parent";
public BD_Desc()
{
//
// TODO: 在此处添加构造函数逻辑
//
this.BuildDataTables();
}
private BD_Desc(SerializationInfo info,StreamingContext
context): base(info,context)
{

}
private void BuildDataTables()
{
DataTable table = new DataTable(BD_DESC_TABLE);
DataColumnCollection columns = table.Columns;
columns.Add(TYPE_FIELD,typeof(System.String));

columns.Add(SUBTYPE_FIELD,typeof(System.String));

columns.Add(DESCRIPTION_FIELD,typeof(System.String));

columns.Add(CVALUES_FIELD,typeof(System.String));

columns.Add(PARENT_FIELD,typeof(System.String));
this.Tables.Add(table);
}

}
}

调用Form1.cs
private BD_Desc dss;
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection con = new SqlConnection("server
=necy;
database=wlerp ;uid=sa;pwd=;");
SqlDataAdapter da = new SqlDataAdapter("select
* from BD_Desc",con);
//DataSet ds= new DataSet();
dss = new BD_Desc();
da.Fill(dss);
this.richTextBox1.Text += "/r/n 记录条数
:"+dss.Tables[0].Rows.Count.ToString();
this.dataGrid1.DataSource = dss;

this.dataGrid1.SetDataBinding(dss,BD_Desc.BD_DESC_TABLE);

}
为什么最后,取不到数据呀,请各位帮我解决一下
 
看不懂:( 顶一下吧
 
我也琢磨过duwamish7,时间长了记不清了.我看了一下,不一定能解决问题啊!
this.dataGrid1.DataSource = dss;
这一句绑定你把该成绑定在
this.dataGrid1.DataSource=dss.Tables[0].DefaultView;//绑定到数据集的第一个视图上
上试试.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
I
回复
0
查看
774
import
I
后退
顶部