还是DataGridView的问题,没办法结贴
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace DataGridView_P
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void B_Ok_Click(object sender, EventArgs e)
{
string sql = "select username,userid,password,serverid from general_user; ";
string source = "server=192.168.0.125;uid=sa;pwd=admin;database=ecs ";
SqlCommand comm = null;
SqlConnection conn = null;
DataSet myDataSet = new DataSet();
conn = new SqlConnection(source);
conn.Open();
SqlDataAdapter myDataAdapter = new SqlDataAdapter(sql,conn);
myDataAdapter.Fill(myDataSet, "general_user ");
//dataGridView1.Columns[0].HeaderText = "这里会出错 ";
为什么一加上上面这一行就会出错呢,我搞不明白,高好来给我看一下好吗?
dataGridView1.DataSource = myDataSet.Tables[ "general_user "].DefaultView;
conn.Close();
}
private void B_Out_Click(object sender, EventArgs e)
{