大家帮帮我改正下啊急用啊
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 温州大学论文_选课_系统
{
public partial class wsxk : Form
{
public wsxk()
{
InitializeComponent();
}
private SqlConnection MyCon, MyCon1;//连接对象
private SqlDataAdapter MyDataAdapter, MyDataAdapter1, MyDataAdapter2;
//数据适配器对象
private DataSet MyDs, MyDs1, MyDs2;
private BindingManagerBase Navigator;
private string ClassID;
private string ClassName;
private DataTable table=new DataTable();
private void DispValue()
{
MyCon1 = new SqlConnection(LoginForm.CString1);//创建连接对象
MyCon1.Open();//打开连接
string SqlStr1 = "select * from 学生网上选课 where 课题编号='"+textBox1.Text+"'"; //设置SQL命令字符串
MyDataAdapter1 = new SqlDataAdapter(SqlStr1, MyCon1);//生成SqlDataAdapter对象
MyDs1 = new DataSet();//产生数据集
MyDataAdapter1.Fill(MyDs1, "student");//填充数据集
string SqlStr2 = "select 课题编号,课程名称,指导老师,备注 from 学生网上选课 where 课题编号='"+textBox1.Text+"' ";
MyDataAdapter2 = new SqlDataAdapter(SqlStr2, MyCon);//生成SqlDataAdapter对象
MyDs2 = new DataSet();//产生数据集
MyDataAdapter2.Fill(MyDs2, "xsxk");//填充数据集
Navigator = this.BindingContext[MyDs2, "xsxk"];
this.dataGrid2.DataSource = MyDs2;
this.dataGrid2.DataMember = "xsxk";
}
private void button1_Click(object sender, EventArgs e)
{
bool f = false;
string AddString;
SqlCommand MyCom = new SqlCommand();
MyCom.Connection = MyCon;
MyCom.CommandType = CommandType.Text;
if (textBox1.Text == "")
MessageBox.Show("请输入要选课学生的学号!", "提示信息");
else
{
}
if (f)
MessageBox.Show("该课程已经选上!");
else
{
AddString="insert into 网上选课表(课题编号,课题名称,指导老师,备注) values('"+textBox1.Text+"','"+textBox2.Text+"') UPDATE 网上选课 教师=(select 教师 from 学生选课表 where 选课序号='"+textBox4.Text+"'),上课地点=(select 上课地点 from 学生选课表 where 选课序号='"+textBox4.Text+"'),上课时间=(select 上课时间 from 学生选课表 where 选课序号='"+textBox4.Text+"') where 选课序号='"+textBox4.Text+"'";
MyCom.CommandText = AddString;
MyCom.ExecuteNonQuery();
MyDataAdapter2.Update(MyDs2, "wsxk");
MyDs2.Clear();
MyDataAdapter2.Fill(MyDs2, "wsxk");
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确定要删除所选课程吗?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
if (Navigator.Count > 0)
{
string strID = this.dataGrid2[this.dataGrid2.CurrentCell.RowNumber, 0].ToString().Trim();
string str = this.dataGrid2[this.dataGrid2.CurrentCell.RowNumber, 1].ToString().Trim();
SqlCommand comn = new SqlCommand(deleteID, MyCon);
comn.ExecuteNonQuery();
Navigator.RemoveAt(Navigator.Position);
try
{
this.MyDataAdapter2.Update(this.table);
}
catch (Exception express)
{
MessageBox.Show(express.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
table.RejectChanges();
}
}
private void button3_Click(object sender, EventArgs e)
{
string SeclectStr = "%";
if (textBox1.Text.Trim() != "")
SeclectStr = "select * 网上选课表 where 课题编号 like '" + textBox1.Text.Trim() + "%'";
MyDataAdapter = new SqlDataAdapter(SeclectStr, MyCon);
MyDs.Clear();
MyDataAdapter.Fill(MyDs, "Curricula");
private void wsxk_Load(object sender, EventArgs e)
{
MyCon = new SqlConnection(LoginForm.CString1);//创建连接对象
MyCon.Open();//打开连接
string SqlStr1 = "select * from 学生网上选课";//设置SQL命令字符串
MyDataAdapter = new SqlDataAdapter(SqlStr1, MyCon);//生成SqlDataAdapter对象
MyDs = new DataSet();//产生数据集
MyDataAdapter.Fill(MyDs, "Curricula");//填充数据集
textBox1.DataBindings.Add("Text", MyDs, "Curricula.课程编号");
textBox2.DataBindings.Add("Text", MyDs, "Curricula.课程名称");
this.dataGrid1.DataSource = MyDs;
this.dataGrid1.DataMember = "Curricula";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void sqlConnection1_InfoMessage(object sender, SqlInfoMessageEventArgs e)
{
}
}
}
调试说出现错误应输入 class、delegate、enum、inte易做图ce 或 struct 的错误请问高手门怎么改正啊? --------------------编程问答-------------------- 没分!代码还这么长!
是哪里少了或者多了大括号了!自己找找吧!
你代码编写很不规范,不然就不会有这错误!
补充:.NET技术 , C#