C#中 sql查询语句该怎么写啊?
//这个写的是关于考试管理系统 查询学生信息的,using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 假期练习
{
public partial class inquire_stu : Form
{
public inquire_stu()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
inquire_type.Text = "";
textBox1.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
if (inquire_type.Text.Trim() == "")
{
MessageBox.Show("请输入查询类型!","提示");
inquire_type.Focus();
}
else if (textBox1.Text.Trim() == "")
{
MessageBox.Show("请输入查询名称!", "提示");
textBox1.Focus();
}
else
{
string connString = @"Data Source=.\sqlexpress;Initial Catalog=kaoshi;Integrated Security=True;Pooling=False";
SqlConnection connection = new SqlConnection(connString);
connection.Open();
if (inquire_type.Text == "用户名")
{
string sql = String.Format("Select count(*) from tab_stu where name='{0}'",textBox1.Text);
//这后面该怎么写显示语句,还有用什么控件显示查询后的数据比较好
}
}
}
}
}
追问:那我该怎么写 ,我是C#初学者 这方面有好多问题 ,就是修改方面也还没解决