有一段关于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();
}
}
}
}