[求助]一个新手问题
我想在combobox中显示数据库中一列的值,不要重复的。可是我的以下代码做出来是全部的值,该怎么改啊!谢谢大家了
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace text5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=127.0.0.1;uid=sa;pwd=;database=master");
con.Open();
SqlCommand sqlcmd = new SqlCommand("select * from spt_datatype_info_ext", con);
SqlDataReader reader = sqlcmd.ExecuteReader();
while (reader.Read())
{
cb.Items.Add(reader[1].ToString());
}
reader.Close();
con.Close();
}
}
}