| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2923 人关注过本帖
标题:有一段关于C#的代码怎样用它连接我的SQL数据库呢?这段代码连接数据库的部分 ...
只看楼主 加入收藏
湘妃竹
Rank: 1
来 自:湖南
等 级:新手上路
帖 子:24
专家分:4
注 册:2016-4-20
结帖率:71.43%
收藏
已结贴  问题点数:11 回复次数:2 
有一段关于C#的代码怎样用它连接我的SQL数据库呢?这段代码连接数据库的部分在哪呢?
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace 停车场管理收费系统
{
    public partial class 系统主界面 : Form
    {
        public 系统主界面()
        {
            InitializeComponent();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            费用设置界面 form = new 费用设置界面();
            form.Show();
            form.MdiParent = this;
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            修改管理员密码界面 form = new 修改管理员密码界面();
            form.Show();
            form.MdiParent = this;
        }

        private void tsbConnect_Click(object sender, EventArgs e)
        {
            if (IC.State||IC.UserConnect()>0)
            {
                tsslTCInfo.Text = "已连接!";
            }
            else
            {
                tsslTCInfo.Text = "连接失败,请检查端口!";
            }
        }

        private void tsbBreak_Click(object sender, EventArgs e)
        {
            IC.UserBreak();
            tsslTCInfo.Text = "已断开连接!";
        }

        private void 系统主界面_Load(object sender, EventArgs e)
        {

        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            会员开户界面 form = new 会员开户界面();
            form.Show();
            form.MdiParent = this;
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            会员缴费界面 form = new 会员缴费界面();
            form.Show();
            form.MdiParent = this;
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            会员注销界面 form = new 会员注销界面();
            form.Show();
            form.MdiParent = this;
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            会员查询界面 form = new 会员查询界面();
            form.Show();
            form.MdiParent = this;
        }

        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            车辆入库界面 form = new 车辆入库界面();
            form.Show();
            form.MdiParent = this;
        }

        private void toolStripButton8_Click(object sender, EventArgs e)
        {
            出库缴费界面 form = new 出库缴费界面();
            form.Show();
            form.MdiParent = this;
        }

        private void toolStripButton11_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("确定退出系统吗?", "系统提示", MessageBoxButtons.YesNo , MessageBoxIcon.Question);
            if (result == DialogResult.Yes)
            {
                this.Close();
            }
           
        }

        private void 系统主界面_FormClosing(object sender, FormClosingEventArgs e)
        {
           
            

        }

        private void 费用设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            费用设置界面 form = new 费用设置界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 修改密码UToolStripMenuItem_Click(object sender, EventArgs e)
        {
            修改管理员密码界面 form = new 修改管理员密码界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 开户OToolStripMenuItem_Click(object sender, EventArgs e)
        {
            会员开户界面 form = new 会员开户界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 充值RToolStripMenuItem_Click(object sender, EventArgs e)
        {

            会员缴费界面 form = new 会员缴费界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 注销CToolStripMenuItem_Click(object sender, EventArgs e)
        {
            会员注销界面 form = new 会员注销界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 查询QToolStripMenuItem_Click(object sender, EventArgs e)
        {
            会员查询界面 form = new 会员查询界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 入库ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            车辆入库界面 form = new 车辆入库界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 出库ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            出库缴费界面 form = new 出库缴费界面();
            form.Show();
            form.MdiParent = this;
        }

        private void 退出XToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("确定退出系统吗?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == DialogResult.Yes)
            {
                this.Close();
            }
        }

    }
}
搜索更多相关主题的帖子: 连接数据库 SQL数据库 private public 停车场 
2016-11-15 13:08
向洪林
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:重庆市奉节县
等 级:版主
威 望:9
帖 子:118
专家分:405
注 册:2015-3-10
收藏
得分:6 
居然问这个问题,去学学.net的

新手上路,望大家多多照顾,谢谢!
2016-11-15 13:17
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
收藏
得分:6 
去看 IC 这个类吧,应该里面有写
2016-11-18 12:07
快速回复:有一段关于C#的代码怎样用它连接我的SQL数据库呢?这段代码连接数据库的 ...
数据加载中...
 
   



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

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