VS2022使用C#语言通过winform开发串口调试工具

1.VS2022环境安装

1.1 官网下载VS2022
进入登录界面(无账号需要注册一个):https://my.visualstudio.com/Benefits?mkt=zh-cn
选择下载界面

在这里插入图片描述

根据电脑配置选择不同的软件版本
在这里插入图片描述
1.2 下载完成后安装VS2022,项目基于C#语言的winfrom开发,必须安装如下两个组件
在这里插入图片描述
可自定义安装路径等(安装路径磁盘大小必须满足安装需求)
在这里插入图片描述

2.新建工程项目

安装完成后启动软件,选择创建新的项目
在这里插入图片描述
配置项目
在这里插入图片描述
创建完成后进入图形化界面,底框大小可调
在这里插入图片描述
从工具箱中可选择需要的组件拉入底框中,同时可配置组件的属性
在这里插入图片描述
可根据需求添加单个/多个串口,将串口组件拖入底框在底部就会出现串口组件
在这里插入图片描述
双击组件可生成组件的实现接口,如button1组件,注意:生成的接口函数不能删除,不然图形化界面就会报错
在这里插入图片描述

3.整体实现

3.1 图形界面
在这里插入图片描述
3.2 组件介绍
串口1和串口2配置使用groupBox组件
端口号、波特率、停止位、数据位、校验位、校准方式都是使用label组件,之后跟着的复选框都是使用comboBox组件
打开串口和开启校准都是使用button组件
数据接收区使用textBox组件,需要打开Multiline属性调为true,打开多行接收

3.3 接口实现
代码

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using System.IO;

namespace CalibrationShow
{
    public partial class Form1 : Form
    {
        bool readFlag = false;
        [DllImport("user32.dll")]
        public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, Keys vk);

        [DllImport("user32.dll")]
        public static extern bool UnregisterHotKey(IntPtr hWnd, int id);

        const int WM_DEVICECHANGE = 0x219;
        const int DBT_DEVICEARRIVAL = 0x8000;
        const int DBT_DEVICEREMOVECOMPLETE = 0x8004;

        // 事件触发接口
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == WM_DEVICECHANGE)
            {
                string[] ports = System.IO.Ports.SerialPort.GetPortNames(); //获取电脑上可用串口号

                switch (m.WParam.ToInt32())
                {
                    case DBT_DEVICEARRIVAL:
                        // USB设备插入
                        //MessageBox.Show("有新设备接入!");
                        comboBox1.Items.Clear();
                        comboBox10.Items.Clear();
                        Thread.Sleep(2);   // 延时
                        comboBox1.Items.AddRange(ports);   // 添加端口必须分开写
                        Thread.Sleep(2);   // 延时
                        comboBox10.Items.AddRange(ports);
                        Thread.Sleep(2);   // 延时
                        comboBox1.SelectedIndex = comboBox1.Items.Count > 0 ? 0 : -1;
                        comboBox10.SelectedIndex = comboBox10.Items.Count > 0 ? 0 : -1;
                        break;
                    case DBT_DEVICEREMOVECOMPLETE:
                        // USB设备移除
                        //MessageBox.Show("有设备移除!");
                        comboBox1.Items.Clear();
                        comboBox10.Items.Clear();
                        Thread.Sleep(2);
                        comboBox1.Items.AddRange(ports);
                        Thread.Sleep(2);
                        comboBox10.Items.AddRange(ports);
                        Thread.Sleep(2);   // 延时
                        comboBox1.SelectedIndex = comboBox1.Items.Count > 0 ? 0 : -1;
                        comboBox10.SelectedIndex = comboBox10.Items.Count > 0 ? 0 : -1;
                        break;
                }
            }
        }

        // 此接口暂时不用
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);
            // 注销WM_DEVICECHANGE消息
            UnregisterHotKey(this.Handle, 1001);
        }

        public Form1()
        {
            InitializeComponent();

            // 注册WM_DEVICECHANGE消息,包括窗口句柄、消息ID、修饰键(0表示无修饰键)、按键
            RegisterHotKey(this.Handle, 1001, 0, Keys.None);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string[] ports = System.IO.Ports.SerialPort.GetPortNames(); //获取电脑上可用串口号
            comboBox1.Items.AddRange(ports);
            comboBox10.Items.AddRange(ports);
            comboBox1.SelectedIndex = comboBox1.Items.Count > 0 ? 0 : -1;
            comboBox10.SelectedIndex = comboBox1.Items.Count > 0 ? 0 : -1;

            // 波特率
            comboBox2.Text = "115200";
            comboBox9.Text = "115200";

            //停止位
            comboBox3.Text = "1";
            comboBox8.Text = "1";

            //数据位
            comboBox4.Text = "8";
            comboBox7.Text = "8";

            //校验位
            comboBox5.Text = "无";
            comboBox6.Text = "无";

            label14.Visible = false;
            comboBox12.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "打开串口")
            {
                try
                {
                    //通信端口设置
                    serialPort1.PortName = comboBox1.Text;
                    serialPort2.PortName = comboBox10.Text;

                    //设置波特率
                    serialPort1.BaudRate = int.Parse(comboBox2.Text);
                    serialPort2.BaudRate = int.Parse(comboBox9.Text);

                    //设置停止位
                    if (comboBox3.Text == "1")
                    {
                        serialPort1.StopBits = System.IO.Ports.StopBits.One;
                    }
                    else if(comboBox3.Text == "1.5")
                    {
                        serialPort1.StopBits = System.IO.Ports.StopBits.OnePointFive;
                    }
                    else if (comboBox3.Text == "2")
                    {
                        serialPort1.StopBits = System.IO.Ports.StopBits.Two;
                    }

                    if (comboBox8.Text == "1")
                    {
                        serialPort2.StopBits = System.IO.Ports.StopBits.One;
                    }
                    else if (comboBox8.Text == "1.5")
                    {
                        serialPort2.StopBits = System.IO.Ports.StopBits.OnePointFive;
                    }
                    else if (comboBox8.Text == "2")
                    {
                        serialPort2.StopBits = System.IO.Ports.StopBits.Two;
                    }

                    //设置数据位
                    serialPort1.DataBits = int.Parse(comboBox4.Text);
                    serialPort2.DataBits = int.Parse(comboBox7.Text);

                    //设置奇偶校验位
                    if (comboBox5.Text == "无")
                    {
                        serialPort1.Parity = System.IO.Ports.Parity.None;
                    }
                    else if (comboBox5.Text == "奇校验")
                    {
                        serialPort1.Parity = System.IO.Ports.Parity.Odd;
                    }
                    else if (comboBox5.Text == "偶校验")
                    {
                        serialPort1.Parity = System.IO.Ports.Parity.Even;
                    }

                    if (comboBox6.Text == "无")
                    {
                        serialPort2.Parity = System.IO.Ports.Parity.None;
                    }
                    else if (comboBox6.Text == "奇校验")
                    {
                        serialPort2.Parity = System.IO.Ports.Parity.Odd;
                    }
                    else if (comboBox6.Text == "偶校验")
                    {
                        serialPort2.Parity = System.IO.Ports.Parity.Even;
                    }

                    //打开串口
                    serialPort1.Open();
                    serialPort2.Open();
                    button1.Text = "关闭串口";
                    comboBox1.Enabled = false;
                    comboBox2.Enabled = false;
                    comboBox3.Enabled = false;
                    comboBox4.Enabled = false;
                    comboBox5.Enabled = false;
                    comboBox6.Enabled = false;
                    comboBox7.Enabled = false;
                    comboBox8.Enabled = false;
                    comboBox9.Enabled = false;
                    comboBox10.Enabled = false;
                }
                catch (Exception err)
                {
                    MessageBox.Show("打开失败"+ err.ToString(),"提示!");
                }
            }
            else
            {
                try
                {
                    if (button2.Text == "关闭校准")
                    {
                        byte[] buff = new byte[8];
                        buff[0] = 0xFA;
                        buff[1] = 0x08;
                        buff[2] = 0x00;
                        buff[3] = 0x01;
                        buff[4] = 0x39;
                        buff[5] = 0x04;
                        buff[6] = 0x00;
                        buff[7] = 0x46;
                        serialPort2.Write(buff, 0, buff.Length);
                        button2.Text = "开启校准";
                        comboBox11.Enabled = true;
                        comboBox12.Enabled = true;
                    }
                    serialPort1.Close();
                    serialPort2.Close();
                    button1.Text = "打开串口";
                    comboBox1.Enabled = true;
                    comboBox2.Enabled = true;
                    comboBox3.Enabled = true;
                    comboBox4.Enabled = true;
                    comboBox5.Enabled = true;
                    comboBox6.Enabled = true;
                    comboBox7.Enabled = true;
                    comboBox8.Enabled = true;
                    comboBox9.Enabled = true;
                    comboBox10.Enabled = true;
                }
                catch (Exception err)
                {
                    MessageBox.Show("关闭失败" + err.ToString(), "提示!");
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (serialPort2.IsOpen)
            {

                if (comboBox11.Text == "全流程校准")
                {
                    if (button2.Text == "开启校准")
                    {
                        if (textBox1.Text == "")
                        {
                            byte[] buff = new byte[8];
                            buff[0] = 0xFA;
                            buff[1] = 0x08;
                            buff[2] = 0x00;
                            buff[3] = 0x01;
                            buff[4] = 0x39;
                            buff[5] = 0x03;
                            buff[6] = 0x01;
                            buff[7] = 0x46;

                            serialPort2.Write(buff, 0, buff.Length);

                            button2.Text = "关闭校准";
                            comboBox11.Enabled = false;
                        }
                        else
                        {
                            MessageBox.Show("请先清除数据!");
                        }
                    }
                    else
                    {
                        byte[] buff = new byte[8];
                        buff[0] = 0xFA;
                        buff[1] = 0x08;
                        buff[2] = 0x00;
                        buff[3] = 0x01;
                        buff[4] = 0x39;
                        buff[5] = 0x03;
                        buff[6] = 0x00;
                        buff[7] = 0x45;
                        serialPort2.Write(buff, 0, buff.Length);
                        button2.Text = "开启校准";
                        comboBox11.Enabled = true;
                    }
                }
                else if (comboBox11.Text == "单阻抗校准")
                {
                    if (button2.Text == "开启校准")
                    {
                        if (textBox1.Text == "")
                        {
                            byte[] buff = new byte[8];
                            buff[0] = 0xFA;
                            buff[1] = 0x08;
                            buff[2] = 0x00;
                            buff[3] = 0x01;
                            buff[4] = 0x39;
                            buff[5] = 0x01;
                            buff[6] = 0x01;
                            buff[7] = 0x44;

                            serialPort2.Write(buff, 0, buff.Length);

                            button2.Text = "关闭校准";
                            comboBox11.Enabled = false;
                        }
                        else
                        {
                            MessageBox.Show("请先清除数据!");
                        }  
                    }
                    else
                    {
                        byte[] buff = new byte[8];
                        buff[0] = 0xFA;
                        buff[1] = 0x08;
                        buff[2] = 0x00;
                        buff[3] = 0x01;
                        buff[4] = 0x39;
                        buff[5] = 0x01;
                        buff[6] = 0x00;
                        buff[7] = 0x43;
                        serialPort2.Write(buff, 0, buff.Length);
                        button2.Text = "开启校准";
                        comboBox11.Enabled = true;
                    }
                }
                else if (comboBox11.Text == "单功率校准")
                {
                    if (button2.Text == "开启校准")
                    {
                        if (textBox1.Text == "")
                        {
                            byte[] buff = new byte[8];
                            buff[0] = 0xFA;
                            buff[1] = 0x08;
                            buff[2] = 0x00;
                            buff[3] = 0x01;
                            buff[4] = 0x39;
                            buff[5] = 0x02;
                            buff[6] = 0x01;
                            buff[7] = 0x45;

                            serialPort2.Write(buff, 0, buff.Length);

                            button2.Text = "关闭校准";
                            comboBox11.Enabled = false;
                        }
                        else
                        {
                            MessageBox.Show("请先清除数据!");
                        }
                    }
                    else
                    {
                        byte[] buff = new byte[8];
                        buff[0] = 0xFA;
                        buff[1] = 0x08;
                        buff[2] = 0x00;
                        buff[3] = 0x01;
                        buff[4] = 0x39;
                        buff[5] = 0x02;
                        buff[6] = 0x00;
                        buff[7] = 0x44;
                        serialPort2.Write(buff, 0, buff.Length);
                        button2.Text = "开启校准";
                        comboBox11.Enabled = true;
                    }
                }
                else if (comboBox11.Text == "自定义校准")
                {
                    if (button2.Text == "开启校准")
                    {
                        if (textBox1.Text == "")
                        {
                            byte[] buff = new byte[8];

                            UInt16 value = Convert.ToUInt16(comboBox12.Text);

                            buff[0] = 0xFA;
                            buff[1] = 0x08;
                            buff[2] = 0x00;
                            buff[3] = (byte)(value & 0xFF);
                            buff[4] = (byte)((value >> 8) & 0xFF);
                            buff[5] = 0x04;
                            buff[6] = 0x01;
                            buff[7] = 0x47;

                            serialPort2.Write(buff, 0, buff.Length);

                            button2.Text = "关闭校准";
                            comboBox11.Enabled = false;
                            comboBox12.Enabled = false;
                        }
                        else
                        {
                            MessageBox.Show("请先清除数据!");
                        }
                    }
                    else
                    {
                        byte[] buff = new byte[8];
                        buff[0] = 0xFA;
                        buff[1] = 0x08;
                        buff[2] = 0x00;
                        buff[3] = 0x01;
                        buff[4] = 0x39;
                        buff[5] = 0x04;
                        buff[6] = 0x00;
                        buff[7] = 0x46;
                        serialPort2.Write(buff, 0, buff.Length);
                        button2.Text = "开启校准";
                        comboBox11.Enabled = true;
                        comboBox12.Enabled = true;
                    }
                }
                else if (comboBox11.Text == "手动功率校准")
                {
                    if (button2.Text == "开启校准")
                    {
                        byte[] buff = new byte[8];
                        buff[0] = 0xFA;
                        buff[1] = 0x08;
                        buff[2] = 0x00;
                        buff[3] = 0x01;
                        buff[4] = 0x39;
                        buff[5] = 0x05;
                        buff[6] = 0x01;
                        buff[7] = 0x48;

                        serialPort2.Write(buff, 0, buff.Length);

                        button2.Text = "关闭校准";
                        comboBox11.Enabled = false;
                    }
                    else
                    {
                        byte[] buff = new byte[8];
                        buff[0] = 0xFA;
                        buff[1] = 0x08;
                        buff[2] = 0x00;
                        buff[3] = 0x01;
                        buff[4] = 0x39;
                        buff[5] = 0x05;
                        buff[6] = 0x00;
                        buff[7] = 0x47;
                        serialPort2.Write(buff, 0, buff.Length);
                        button2.Text = "开启校准";
                        comboBox11.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("请选择校准模式!");
                }
            }
            else
            {
                MessageBox.Show("请先打开串口!");
            }

        }

        private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            int len = serialPort1.BytesToRead;//获取可以读取的字节数
            byte[] buff = new byte[len];//创建缓存数据数组
            byte[] buff1 = new byte[len+1];//创建缓存数据数组
 
            serialPort1.Read(buff, 0, len);//把数据读取到buff数组

            string str = Encoding.Default.GetString(buff);//Byte值根据ASCII码表转为 String

            if (len > 2)
            {
                Invoke((new Action(() => //C# 3.0以后代替委托的新方法
                {
                    textBox1.AppendText(str);//对话框追加显示数据
                })));

                buff1[0] = 0xFB;
                // 从buff的第0个元素(索引为0)开始复制len个元素,从buff1的第二个元素开始保存这复制的len个元素
                Array.Copy(buff, 0, buff1, 1, len);

                if(readFlag)
                {
                    serialPort2.Write(buff1, 0, buff1.Length);
                    readFlag = false;
                }
            }
        }

        private void serialPort2_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            int len = serialPort2.BytesToRead;//获取可以读取的字节数
            byte[] buff = new byte[len];//创建缓存数据数组

            serialPort2.Read(buff, 0, len);//把数据读取到buff数组

            string str = Encoding.Default.GetString(buff);//Byte值根据ASCII码表转为 String

            Invoke((new Action(() => //C# 3.0以后代替委托的新方法
            {
                textBox2.AppendText(str);//对话框追加显示数据
            })));

            if (str == "Calibra")
            {
                MessageBox.Show("阻抗校准完成!");
                button2.Invoke(new Action(() =>
                {
                    button2.Text = "开启校准";
                }));
                comboBox11.Invoke(new Action(() =>
                {
                    comboBox11.Enabled = true;
                }));
            }
            else if (str == "Power")
            {
                MessageBox.Show("功率校准完成!");
                button2.Invoke(new Action(() =>
                {
                    button2.Text = "开启校准";
                }));
                comboBox11.Invoke(new Action(() =>
                {
                    comboBox11.Enabled = true;
                }));
                if (comboBox11.Text == "自定义校准")
                {
                    comboBox12.Invoke(new Action(() =>
                    {
                        comboBox12.Enabled = true;
                    }));
                }
            }
            else if (str == "ALL")
            {
                MessageBox.Show("全流程校准完成!");
                button2.Invoke(new Action(() =>
                {
                    button2.Text = "开启校准";
                }));
                comboBox11.Invoke(new Action(() =>
                {
                    comboBox11.Enabled = true;
                }));
                if (comboBox11.Text == "自定义校准")
                {
                    comboBox12.Invoke(new Action(() =>
                    {
                        comboBox12.Enabled = true;
                    }));
                }
            }
            else if (str == "error")
            {
                MessageBox.Show("ready按键被关闭!");
                button2.Invoke(new Action(() =>
                {
                    button2.Text = "开启校准";
                }));
                comboBox11.Invoke(new Action(() =>
                {
                    comboBox11.Enabled = true;
                }));

                if(comboBox11.Text == "自定义校准")
                {
                    comboBox12.Invoke(new Action(() =>
                    {
                        comboBox12.Enabled = true;
                    }));
                }
            }
            else if (str == "power data error!\r\n")
            { 

            }
            else if (str == "curr data error!\r\n")
            {

            }
            else
            {
                if (str.Length > 5)
                {
                    serialPort1.Write(str);
                    if(str == "READ:ALL?\r\n")
                    {
                        readFlag = true;
                    }
                }
            }
        }

        private void comboBox11_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox11.Text == "自定义校准")
            {
                label14.Visible = true;
                comboBox12.Visible = true;
            }
            else
            {
                label14.Visible = false;
                comboBox12.Visible = false;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox3.Text == "")
            {
                MessageBox.Show("请先输入设备编号");
            }
            else 
            {
                if(textBox1.Text == "")
                {
                    MessageBox.Show("无数据需要保存!");
                }
                else
                {
                    if (button2.Text == "开启校准")
                    {
                        string text = textBox1.Text;
                        string text1 = textBox3.Text + ".txt";  //追加文件后缀名
                        string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                        string filePath = Path.Combine(desktopPath, text1);

                        File.WriteAllText(filePath, text);     //将数据保存到本地桌面
                    }
                    else
                    {
                        MessageBox.Show("请关闭校准后再保存数据!");
                    }
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (button2.Text == "开启校准")
            {
                textBox1.Text = "";
                textBox2.Text = "";
            }
            else 
            {
                MessageBox.Show("请关闭校准后再清除数据!");
            }
        }
    }
}

  • 10
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Preface..................................................................................................................................9 Organization of This Book........................................................................................9 Conventions Used in This Book..............................................................................9 How to Contact Us....................................................................................................10 Acknowledgments.....................................................................................................11 Chapter 1. Introduction.....................................................................................................13 1.1 What Is the Microsoft .NET Framework?..................................................13 1.2 What Is Visual Basic .NET?............................................................................14 1.3 An Example Visual Basic .NET Program...................................................14 Chapter 2. The Visual Basic .NET Language...............................................................23 2.1 Source Files.........................................................................................................23 2.2 Identifiers.............................................................................................................23 2.3 Keywords..............................................................................................................24 2.4 Literals...................................................................................................................27 2.5 Types......................................................................................................................31 2.6 Namespaces........................................................................................................40 2.7 Symbolic Constants..........................................................................................42 2.8 Variables...............................................................................................................43 2.9 Scope......................................................................................................................44 2.10 Access Modifiers..............................................................................................44 2.11 Assignment........................................................................................................45 2.12 Operators and Expressions.........................................................................46 2.13 Statements........................................................................................................52 2.14 Classes................................................................................................................60 2.15 Interfaces...........................................................................................................85 2.16 Structures..........................................................................................................88 2.17 Enumerations...................................................................................................91 2.18 Exceptions..........................................................................................................93 2.19 Delegates...........................................................................................................98 2.20 Events................................................................................................................101 2.21 Standard Modules.........................................................................................104 2.22 Attributes.........................................................................................................104 2.23 Conditional Compilation.............................................................................108 2.24 Summary..........................................................................................................109 Chapter 3. The .NET Framework..................................................................................111 3.1 Common Language Infrastructure (CLI) and Common Language Runtime (CLR)..........................................................................................................111 3.2 Common Type System (CTS).....................................................................111 3.3 Portions of the CLI..........................................................................................112 3.4 Modules and Assemblies...............................................................................113 3.5 Application Domains.......................................................................................116 3.6 Common Language Specification (CLS).................................................116 3.7 Intermediate Language (IL) and Just-In-Time (JIT) Compilation117 3.8 Metadata.............................................................................................................117 3.9 Memory Management and Garbage Collection....................................118 3.10 A Brief Tour of the .NET Framework Namespaces...........................122 Programming Visual Basic .NET 3 3.11 Configuration...................................................................................................125 3.12 Summary..........................................................................................................131 Chapter 4. Windows Forms I: Developing Desktop Applications.............................133 4.1 Creating a Form................................................................................................133 4.2 Handling Form Events....................................................................................143 4.3 Relationships Between Forms.....................................................................145 4.4 MDI Applications...............................................................................................147 4.5 Component Attributes....................................................................................155 4.6 2-D Graphics Programming with GDI+...................................................160 4.7 Printing.................................................................................................................174 4.8 Summary.............................................................................................................186 Chapter 5. Windows Forms II: Controls, Common Dialog Boxes, and Menus......187 5.1 Common Controls and Components.........................................................187 5.2 Control Events...................................................................................................204 5.3 Form and Control Layout..............................................................................204 5.4 Common Dialog Boxes...................................................................................210 5.5 Menus...................................................................................................................215 5.6 Creating a Control...........................................................................................227 5.7 Summary.............................................................................................................236 Chapter 6. ASP.NET and Web Forms: Developing Browser-Based Applications237 6.1 Creating a Web Form.....................................................................................238 6.2 Handling Page Events.....................................................................................251 6.3 More About Server Controls........................................................................253 6.4 Adding Validation.............................................................................................268 6.5 Using Directives to Modify Web Page Compilation.............................283 6.6 ASP.NET Objects: Interacting with the Framework...........................291 6.7 Discovering Browser Capabilities...............................................................296 6.8 Maintaining State.............................................................................................298 6.9 Application-Level Code and global.asax.................................................304 6.10 Web-Application Security...........................................................................307 6.11 Designing Custom Controls.......................................................................320 6.12 Summary..........................................................................................................328 Chapter 7. Web Services................................................................................................329 7.1 Creating a Web Service.................................................................................329 7.2 Testing a Web Service with a Browser....................................................333 7.3 Web-Service Descriptions.............................................................................335 7.4 Consuming a Web Service............................................................................335 7.5 Web-Service Discovery..................................................................................340 7.6 Limitations of Web Services........................................................................340 7.7 Summary.............................................................................................................341 Chapter 8. ADO.NET: Developing Database Applications.......................................343 8.1 A Brief History of Universal Data Access................................................343 8.2 Managed Providers..........................................................................................343 8.3 Connecting to a SQL Server Database....................................................344 SQL Server Authentication.............................................................................................347 8.4 Connecting to an OLE DB Data Source...................................................348 8.5 Reading Data into a DataSet.......................................................................349 4 8.6 Relations Between DataTables in a DataSet........................................360 8.7 The DataSet's XML Capabilities.................................................................362 8.8 Binding a DataSet to a Windows Forms DataGrid..............................364 8.9 Binding a DataSet to a Web Forms DataGrid.......................................367 8.10 Typed DataSets.............................................................................................368 8.11 Reading Data Using a DataReader.........................................................370 8.12 Executing Stored ProceduresThrough a SqlCommand Object....371 8.13 Summary..........................................................................................................374 Appendix A. Custom Attributes Defined in the System Namespace......................375 Appendix B. Exceptions Defined in the System Namespace...................................381 Appendix D. Resources for Developers......................................................................391 D.1 .NET Information.............................................................................................391 D.2 Discussion Lists................................................................................................392 Netiquette.........................................................................................................................392 Appendix E. Math Functions..........................................................................................395 Colophon...........................................................................................................................398

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值