System.Windows.Forms.DataGridView"不包含"Bind"的定义,并且找不到可接受类型为"

qq_43235351 2019-02-18 05:03:14
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace zuoye2
{
public partial class frmCHA : Form
{
public frmCHA()
{
InitializeComponent();
}

//连接数据库据
string str = "Data Source=074B8J5ZEZU39W3\\SQLEXPRES;Initial Catalog=AirQualityDB;Integrated Security=True";
SqlConnection conn = new SqlConnection();//申明数据库连接

//主窗体
private void frmCHA_Load(object sender, EventArgs e)
{
BindAirQualityInfo();
}

//查询
private void BTNCHA_Click(object sender, EventArgs e)
{



}

public void BindAirQualityInfo()
{

SqlConnection conn = new SqlConnection(str);//连接
string cha = txtBoxCHA01.Text.Trim();//sql语句
string sql = string.Format("select * from AirQualityInfo,StationInfo where like '%{0}%'", cha);

SqlDataAdapter adapter = new SqlDataAdapter(sql,conn);//数据适配器
DataSet ds = new DataSet();//数据集
try
{
adapter.Fill(ds,"stu");//填充数据
dataGridView1.DataSource = ds;//绑定数据源
dataGridView1.Bind();
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
BindAirQualityInfo();
}

private void txtBoxCHA01_TextChanged(object sender, EventArgs e)
{

}
}
}

...全文
523 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
Winform中的datagridview不需要Bind(),asp.net 中的需要。
_小黑_ 2019-02-18
  • 打赏
  • 举报
回复
datagrid.datasource = 数据源

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧