啊啊 c shape 大神求解啊
c吧
全部回复
仅看楼主
level 1
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 ScoreManegement
{
public partial class SearchForm : Form
{
private string sql = "";
private string connStr = @"Data Source = .\sqlexpress;Initial Catalog = 222; Integrated Security = True";
public SearchForm()
{
InitializeComponent();
}
private void SearchForm_Load(object sender, EventArgs e)
{
string _sql = "select XH as'学号',XM as '姓名', ZY as'专业', XB as '性别'," + " CSRQ as '出生日期‘, ZXF as ' 总学分 ',BZ as '备注' from XSB ";
SqlConnection conn = new SqlConnection(connStr);
SqlDataAdapter sda = new SqlDataAdapter(_sql, conn);
DataSet ds = new DataSet ( );
sda.Fill(ds);
StuDGV.DataSource = ds.Tables[0].DefaultView;
stuZY.SelectedIndex = 0;
}
private void MakeSqlStr()
{
sql = "";
if (stuXH.Text.Trim()!=string.Empty)
{
sql = "and XH like'%"+stuXH.Text.Trim ()+"%'";
}
if (stuXM.Text.Trim()!=string.Empty)
{
sql = "and XM like'%"+stuXM.Text.Trim()+"%'";
}
if (stuZY .Text!="所有专业")
{
sql+="and ZX='"+ stuZY.Text+"";
}
}
private void search_btn_Click(object sender, EventArgs e)
{
MakeSqlStr();
string _sql = "select XH as'学号',XM as '姓名', ZY as'专业', XB as '性别'," + "CSRQ as '出生日期‘,ZXF as '总学分',BZ as '备注' from XSB where 1=1" + sql;
SqlConnection conn = new SqlConnection(connStr);
SqlDataAdapter sda = new SqlDataAdapter(_sql, conn);
DataSet ds = new DataSet ( );
sda.Fill(ds);
StuDGV.DataSource = ds.Tables[0].DefaultView;
}
private void stuXM_TextChanged(object sender, EventArgs e)
{
}
}
}
这是程序
2016年06月28日 11点06分 1
level 1
编写 时提示没错误,但在调试时提示 总学分附近有语法错误
2016年06月28日 11点06分 2
level 1
字符串 “from XBS”后的引号不完整
2016年06月28日 11点06分 3
大哥,哪里错了
2022年11月16日 11点11分
level 1
求解啊!求解
2016年06月28日 11点06分 4
level 1
是不是尝了点。。。。
2016年06月28日 11点06分 5
level 5
专业调试
2016年06月30日 10点06分 7
1