数据库查寻显示问题
程序代码:using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
namespace 学生档案
{
public partial class 课程查询 : Form
{
protected SqlCommand sqlcmd;
protected SqlConnection sqlconn;
protected 学生档案DataSetTableAdapters.课程TableAdapter adapter;
public 课程查询()
{
InitializeComponent();
}
private void 课程查询_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“学生档案DataSet.课程”中。您可以根据需要移动或移除它。
this.课程TableAdapter.Fill(this.学生档案DataSet.课程);
try
{
sqlconn = new SqlConnection("Data Source=CHINA-658C3B258;Initial Catalog=学生档案;Integrated Security=True");
sqlconn.Open();
adapter = new 学生档案.学生档案DataSetTableAdapters.课程TableAdapter();
adapter.Fill(学生档案DataSet.课程);
dataGridView1.DataSource = 学生档案DataSet.课程.DefaultView;
}
catch (Exception exp)
{
MessageBox.Show("数据连接失败:" + exp.Message);
Close();
}
finally
{
if (sqlconn != null && sqlconn.State != ConnectionState.Closed)
sqlconn.Close();
}
}
private string GetFilter()
{
StringBuilder sb1 = new StringBuilder();
if(checkBox1.Checked)
sb1.Append(string.Format("Number Like'%{0}%'",textBox1.Text));
if (checkBox2.Checked)
sb1.Append(string.Format("Number Like'%{0}%", textBox2.Text));
return sb1.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if (!checkBox1.Checked && !checkBox2.Checked)
{
MessageBox.Show("", "", MessageBoxButtons.YesNoCancel);
return;
}
if (checkBox1.Checked && textBox1.Text == "")
{
MessageBox.Show("","",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox1.Focus();
return;
}
if (checkBox2.Checked && textBox2.Text == "")
{
MessageBox.Show("","",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox2.Focus();
return;
}
学生档案DataSet.课程.DefaultView.RowFilter = this.GetFilter();
}
}
}
为什么我这个是不能把我查寻到的数据显示出来呢!老提示说 学生档案DataSet.课程.DefaultView.RowFilter = this.GetFilter();未找到列 [Number]。是不是上面的哪里出了什么问题,这里我其实是从书上抄上去了,可就是不能显示出找到的数据?









