日期:2014-05-17  浏览次数:20932 次

串口接收,数据库插入问题,求助
串口接收代码:

private static void DataReceviedHandler(
                        object sender,
                        SerialDataReceivedEventArgs e)
        {
            SerialPort sp = (SerialPort)sender;
            string indata = sp.ReadExisting();
            insertStr += indata;
            
            foreach (char ch in insertStr)
            {
                if (ch != 'E' && ch != 'S'&& ch != 'o')
                {
                    usingStr += ch;
                }
            }

            
            string RealName = "";
            switch (usingStr)
            {
                case "2011072069\0":
                    RealName = "a";
                    break;
                case "2010073065\0":
                    RealName = "b";
                    break;
                case "2011072069":
                    RealName = "a";
                    break;
                case "2010073065":
                    RealName = "b";
                    break;
 default:
                 &nb