而且 我使用官网上的数据绑定代码
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web.UI;
namespace ControlExplorer.samples.DataBinding
{
public partial class Overview : SpreadDemoPage
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
//FarPoint.Web.Spread.DefaultSkins.GetAt(1).Apply(FpSpread1.Sheets[0]);
FpSpread1.CommandBar.BackColor = Color.Wheat;
//Set the database connection
DataGrid1.DataSource = GetSuppliers();
FpSpread1.DataSource = GetSuppliers();
Page.DataBind();
//Set the widths
FpSpread1.ActiveSheetView.Columns[0].Width = 60;
FpSpread1.ActiveSheetView.Columns[1].Width = 350;
this.FpSpread1.UseClipboard = false;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
DataSet GetSuppliers()
{
string constr = @"rovider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Northwind.mdbersist Security Info=True";
string sqlstr =
@"SELECT TOP 23
SupplierID as 供应商编号,
CompanyName as 公司名称,
ContactName as 注册名称 ,
ContactTitle as 职位,
Address as 地址,
City as 城市,
Region as 区域,
PostalCode as 邮政编码,
Country as 国家,
Phone as 电话,
Fax as 传真,
HomePage as 主页
FROM suppliers";
DataSet suppliers = new DataSet();
using (OleDbConnection myconn = new OleDbConnection(constr))
{
OleDbDataAdapter sqlAdapter1 = new OleDbDataAdapter(sqlstr, myconn);
sqlAdapter1.Fill(suppliers, "Suppliers");
}
return suppliers;
}
}
}
仍然提示错误 5 无法将类型“System.Data.DataSet”隐式转换为“msdatasrc.DataSource”。存在一个显式转换(是否缺少强制转换?)
在 FpSpread1.DataSource = GetSuppliers();这一行 |