| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3761 人关注过本帖
标题:c#学生信息管理系统
只看楼主 加入收藏
软件二叔
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-9-20
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
c#学生信息管理系统
1! 注册的信息无法进入数据库!!!
2! 管理员对数据库内的学生信息的修改和查询代码!!!
/*------------------注册代码-----------------------*/
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace WindowsFormsApplication1
{
    public partial class Formregister : Form
    {
        public Formregister()
        {
            InitializeComponent();
        }

        private void Formregister_Load(object sender, EventArgs e)
        {

        }
        public bool bbool;

        private void buttonconform_Click(object sender, EventArgs e)
        {
            Formlog f2 = new Formlog();
            string User, Pwd;

            string StrConnection = @"Data Source=JIAOWOERYE-PC;Initial Catalog=mydatabase;Integrated Security=True";
            SqlConnection con = new SqlConnection(StrConnection);
            con.Open();
            string str= "select * from TableStudent";

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
             = str;
             = CommandType.Text;
            cmd.ExecuteNonQuery();
            SqlDataReader reader = cmd.ExecuteReader();
            while(reader.Read())
            {
                User = reader["studentName"].ToString();
                Pwd = reader["mima"].ToString();
            
             if (textBoxname.Text.Trim () == reader["studentName"].ToString().Trim())
            {
                MessageBox.Show("用户存在");
                bbool =true;
                return;                 }
            else
            if (textBoxname.Text.Trim() != reader["studentName"].ToString().Trim())
            {
                MessageBox.Show("恭喜,该用户名可以使用");
                bbool = false;
            }
            }
            if (bbool == false)
            {
                = "insert into TableStudent values('" + textBoxnum.Text + "','" + textBoxname.Text + "','" + textBoxclass.Text + "','" + textBoxmima.Text + "','" + textBoxrealname.Text + "')";

                con.Close();
                MessageBox.Show("注册成功!");
               
                f2.Show();//运行登陆程序
                this.Hide();

            }


            
               
            }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Formlog f2 = new Formlog();
            f2.Show();
        }
    }
}


/*---------------------------------------管理员管理代码------------------------*/
//有错误,要求读取后可以选中一项修改,求大神更改
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
    public partial class Formcontrol : Form
    {
        public Formcontrol()
        {
            InitializeComponent();
        }

        private void comboBoxnumber_SelectedIndexChanged(object sender, EventArgs e)
        {
            string StrConnection = @"Data Source=JIAOWOERYE-PC;Initial Catalog=mydatabase;Integrated Security=True";
            SqlConnection con = new SqlConnection(StrConnection);
            con.Open();


            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
             = CommandType.Text;

             = "select studentNumber from TableStudent where studentNumber =" + comboBoxnumber.Text;
            SqlDataReader reader = cmd.ExecuteReader();


            reader.Read();

            textBoxnum.Text = reader.GetValue(reader.GetOrdinal("studentNumber")).ToString().Trim();
            textBoxrealname.Text = reader.GetValue(reader.GetOrdinal("studentName")).ToString().Trim();
            textBoxmima.Text = reader.GetValue(reader.GetOrdinal("male")).ToString().Trim();
            textBoxname.Text = reader.GetValue(reader.GetOrdinal("age")).ToString().Trim();
            //textBoxdepart.Text = reader.GetValue(reader.GetOrdinal("deparement")).ToString().Trim();
            textBoxclass.Text = reader.GetValue(reader.GetOrdinal("class")).ToString().Trim();


        }

        private void buttonchange_Click(object sender, EventArgs e)
        {

        }
    }
    }
//}
搜索更多相关主题的帖子: 管理系统 public 管理员 数据库 信息 
2016-01-13 20:37
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
收藏
得分:10 
只有语句,你执行了吗??

没有写执行的语句,怎么会插进去呢?
2016-01-14 09:56
mz135135
Rank: 2
等 级:论坛游民
帖 子:2
专家分:10
注 册:2015-10-16
收藏
得分:10 
回复 楼主 软件二叔
没有Sql语句定义个SQL语句然后
 

string sql1 = String.Format("update stu set xm='{0}',xb='{1}',zy='{2}',bj='{3}',ss='{4}',fdy='{5}' where xh='{6}'",txtXm.Text,txtXb.Text,txtZY.Text,txtBj.Text,txtSs.Text,txtFdy.Text,txtXh.Text);//自己更换表名
           
SqlCommand cmd=new SqlCommand(sql1,con);   
            
int a= cmd.ExecuteNonQuery();
2016-01-17 10:59
软件二叔
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-9-20
收藏
得分:0 
2016-02-13 14:45
lichen55212
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-3-1
收藏
得分:0 
2016-03-01 19:48
快速回复:c#学生信息管理系统
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029733 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved