好的,我有一个 SQL 查询,需要在单击按钮时运行,然后输出到数据集。
public partial class Form1 : Form
{
private void Form1_Load(object sender, EventArgs e)
{
Assembly.GetExecutingAssembly().GetName().Version.ToString();
var line = txtLine.Text;
var serial = txtSerial.Text;
var station = txtStation.Text;
}
private void btnGo_Click(object sender, EventArgs e)
{
var line = txtLine.Text;
var serial = txtSerial.Text;
var station = txtStation.Text;
if (txtLine.Text.Trim().Length == 0)
{
MessageBox.Show("Please enter a Line");
}
else if (txtSerial.Text.Trim().Length == 0)
{
MessageBox.Show("Please enter a Serial");
}
else if (txtStation.Text.Trim().Length == 0)
{
MessageBox.Show("Please enter a Station");
}
else
{
//SQL command goes here.
}
}
}
我有 SQL 命令,我只需要知道如何将其作为非存储过程执行并将数据输出到 dataGridView1 对象。