查看 SQL 数据到 dateTimePicker

问题描述 投票:0回答:0

如何将SQL Server 中保存的数据带入dateTimePicker 值? 我的代码不起作用!

public partial class form1 : Form
{
    public form1()
    {
        SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\jack\Documents\events.mdf;Integrated Security=True;Connect Timeout=30");
        con.Open();

        SqlCommand cmd = new SqlCommand("select date1 from Tbbus where date1@date1", con);
        cmd.Parameters.AddWithValue("date", dateTimePicker1.Value);

        SqlDataReader reader;

        InitializeComponent();
    }
}

我试过其他方法还是不行

c# windows-forms-designer
© www.soinside.com 2019 - 2024. All rights reserved.