资源简介

SqlServer服务器连接教程。教程地址http://blog.csdn.net/fengya1/article/details/79401037

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SQLServer
{
    public partial class Form1 : Form
    {
        SQLServerConnectionTool sQLServerConnectionTool;
        public Form1()
        {
            InitializeComponent();
            sQLServerConnectionTool = new SQLServerConnectionTool();
            sQLServerConnectionTool.serverConnetion();

            dataTable = new DataTable();
            dataGridView1.DataSource = dataTable;
        }
        string cmd = “SELECT * FROM UserInfor“;
        string addCmd = “insert into UserInfor values(5‘zcy‘026‘‘)“;
        string delete = “DELETE FROM UserInfor WHERE UserId = 3“;

        DataTable dataTable;
        private void button1_Click(object sender EventArgs e)
        {



            //sQLServerConnectionTool.SqlCommandExeCute(delete);
            //sQLServerConnectionTool.SqlCommandExeCute(addCmd);

            //dataGridView1.DataSource = sQLServerConnectionTool.DataTableSqlDeleteExeCute(delete);


              sQLServerConnectionTool.DataTableSqlSelectExeCute(dataTable);

            // sQLServerConnectionTool.SqlCommandSelectExeCute(cmd);
            //sQLServerConnectionTool.DataTableSqlInsertExeCute(addCmd);
            //dataGridView1.DataSource = sQLServerConnectionTool.DataTableSqlSelectExeCute(cmd);
            //dataGridView1.DataSource = sQLServerConnectionTool.DataTableSqlInsertExeCute(addCmd);
        }

        private void button2_Click(object sender EventArgs e)
        {
            int row;
            if(int.TryParse(textBox1.Text out row))

                sQLServerConnectionTool.DataTableSqlDeleteExeCute(dataTablerow);

        }

        private void button3_Click(object sender EventArgs e)
        {
            if (dataTable.Columns.Count != 5)
            {
                MessageBox.Show(“请先查询数据“);
            }
            int userId;
            int sex;
            int age;

            if (int.TryParse(textBox2.Text out userId) && int.TryParse(textBox4.Text out sex) && int.TryParse(textBox5.Text out age))
            {
                sQLServerConnectionTool.DataTableSqlInsertExeCute(dataTable userId textBox3.Text sex age textBox6.Text);
            }
            else
            {
                MessageBox.Show(“数据填写错误“);
            }
        }

        private void button4_Click(object sender EventArgs e)
        {
            sQLServerConnectionTool.SqlCommandExeCute(textBox7.Text);  //执行sql语句
            sQLServerConnectionTool.DataTableSqlSelectExeCute(dataTable);       //刷新界面
        }

        private void textBox2_KeyPress(object sender KeyPressEventArgs e)
        {
 
            if (!char.IsNumber(e.KeyChar) && e.KeyChar != 8)
            {

                e.Hand

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-02-27 21:05  SQLServer\
     目录           0  2018-02-27 21:05  SQLServer\.vs\
     目录           0  2018-02-27 21:05  SQLServer\.vs\SQLServer\
     目录           0  2018-02-27 21:05  SQLServer\.vs\SQLServer\v15\
     文件       66560  2018-02-28 15:14  SQLServer\.vs\SQLServer\v15\.suo
     目录           0  2018-02-27 21:05  SQLServer\.vs\SQLServer\v15\Server\
     目录           0  2018-02-28 15:14  SQLServer\.vs\SQLServer\v15\Server\sqlite3\
     文件           0  2018-02-27 21:06  SQLServer\.vs\SQLServer\v15\Server\sqlite3\db.lock
     文件      622592  2018-02-28 15:14  SQLServer\.vs\SQLServer\v15\Server\sqlite3\storage.ide
     目录           0  2018-02-28 15:11  SQLServer\SQLServer\
     文件         189  2018-02-27 17:52  SQLServer\SQLServer\App.config
     文件       10553  2018-02-28 14:35  SQLServer\SQLServer\Form1.Designer.cs
     文件        3785  2018-02-28 14:35  SQLServer\SQLServer\Form1.cs
     文件        5817  2018-02-28 14:35  SQLServer\SQLServer\Form1.resx
     文件         521  2018-02-27 17:52  SQLServer\SQLServer\Program.cs
     目录           0  2018-02-27 21:05  SQLServer\SQLServer\Properties\
     文件        1316  2018-02-27 17:52  SQLServer\SQLServer\Properties\AssemblyInfo.cs
     文件        2831  2018-02-27 17:52  SQLServer\SQLServer\Properties\Resources.Designer.cs
     文件        5612  2018-02-27 17:52  SQLServer\SQLServer\Properties\Resources.resx
     文件        1096  2018-02-27 17:52  SQLServer\SQLServer\Properties\Settings.Designer.cs
     文件         249  2018-02-27 17:52  SQLServer\SQLServer\Properties\Settings.settings
     文件        3722  2018-02-27 21:23  SQLServer\SQLServer\SQLServer.csproj
     文件        6821  2018-02-28 15:11  SQLServer\SQLServer\SQLServerConnectionTool.cs
     文件        2578  2018-02-27 21:22  SQLServer\SQLServer\Test.cs
     目录           0  2018-02-27 21:05  SQLServer\SQLServer\bin\
     目录           0  2018-02-27 21:05  SQLServer\SQLServer\bin\Debug\
     文件       17408  2018-02-28 15:11  SQLServer\SQLServer\bin\Debug\SQLServer.exe
     文件         189  2018-02-27 17:52  SQLServer\SQLServer\bin\Debug\SQLServer.exe.config
     文件       32256  2018-02-28 15:11  SQLServer\SQLServer\bin\Debug\SQLServer.pdb
     目录           0  2018-02-28 15:14  SQLServer\SQLServer\bin\Release\
     目录           0  2018-02-27 21:05  SQLServer\SQLServer\obj\
............此处省略16个文件信息

评论

共有 条评论