• 大小: 582KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: C#
  • 标签:

资源简介

让更多的人知道如何用C#操作斑马条码打印机,多格式,多种通讯方式打印

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Text;
using System.IO;

namespace 扫码打印工具
{
    public class AccessHelper
    {
        protected static OleDbConnection conn = new OleDbConnection();
        protected static OleDbCommand comm = new OleDbCommand();

        private string dbpath = ““;

        public AccessHelper(string path)
        {
            dbpath = path;
        }

        /// 
        /// 打开数据库
        /// 

        private void Connection()
        {
            string dsource = dbpath;
            if (!System.IO.File.Exists(dsource))
            {
                throw new Exception(“未找到数据文件!“);
            }
            if (conn.State == ConnectionState.Closed)
            {
                //conn.ConnectionString = @“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=“ + AppDomain.CurrentDomain.baseDirectory + ConfigurationManager.AppSettings[“myconn“].ToString() + “;Jet OLEDB:Database PassWord=sa“;
                conn.ConnectionString = @“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=“ + dsource + “;Persist Security Info=False“;
                //conn.ConnectionString = @“Provider=Microsoft.Jet.OLEDB.12.0;Data Source=Results.Mdb;Persist Security Info=False“;
                comm.Connection = conn;
                try
                {
                    conn.Open();
                }
                catch (Exception e)
                {
                    if (e.Message.IndexOf(“4.0“) > -1)
                    {
                        try
                        {
                            conn.ConnectionString = @“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=“ + dsource + “;Persist Security Info=False“;
                            comm.Connection = conn;
                            conn.Open();
                        }
                        catch (Exception ex) { throw new Exception(ex.Message); }
                    }
                    else
                    {
                        throw new Exception(e.Message);
                    }
                }

            }

        }
        /// 
        /// 关闭数据库
        /// 

        private void DisConnection()
        {
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
                conn.Dispose();
                comm.Dispose();
            }
        }
        /// 
        /// 执行sql语句
        /// 

        /// 
        public void EexcuteSql(string sqlstr)
        {
            try
            {
                Connection();
                comm.CommandType = CommandType.Text;
                comm.CommandText = sqlstr;
                comm.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                throw new Exception(e.Mess

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     53248  2019-04-04 15:44  扫码打印工具\.vs\扫码打印工具\v15\.suo

     文件          0  2019-04-04 15:42  扫码打印工具\.vs\扫码打印工具\v15\Server\sqlite3\db.lock

     文件       4096  2019-04-04 15:42  扫码打印工具\.vs\扫码打印工具\v15\Server\sqlite3\storage.ide

     文件      32768  2019-04-04 15:42  扫码打印工具\.vs\扫码打印工具\v15\Server\sqlite3\storage.ide-shm

     文件     712792  2019-04-04 15:44  扫码打印工具\.vs\扫码打印工具\v15\Server\sqlite3\storage.ide-wal

     文件       9004  2018-02-08 11:49  扫码打印工具\扫码打印工具\AccessHelper.cs

     文件        144  2018-02-27 17:32  扫码打印工具\扫码打印工具\App.config

     文件    4063232  2018-03-02 13:07  扫码打印工具\扫码打印工具\bin\Debug\2017-09-14.Mdb

     文件     214016  2017-10-31 20:34  扫码打印工具\扫码打印工具\bin\Debug\Trace.Common.UnicodeToZPL.dll

     文件       4659  2017-10-31 20:31  扫码打印工具\扫码打印工具\bin\Debug\Trace.Common.UnicodeToZPL.xml

     文件      60928  2018-03-02 13:57  扫码打印工具\扫码打印工具\bin\Debug\扫码打印工具.exe

     文件        160  2018-03-02 11:58  扫码打印工具\扫码打印工具\bin\Debug\扫码打印工具.exe.config

     文件      67072  2018-03-02 13:57  扫码打印工具\扫码打印工具\bin\Debug\扫码打印工具.pdb

     文件      11600  2018-03-02 11:39  扫码打印工具\扫码打印工具\bin\Debug\扫码打印工具.vshost.exe

     文件        144  2018-02-27 17:32  扫码打印工具\扫码打印工具\bin\Debug\扫码打印工具.vshost.exe.config

     文件        490  2010-03-17 22:39  扫码打印工具\扫码打印工具\bin\Debug\扫码打印工具.vshost.exe.manifest

     文件       8893  2018-03-02 13:57  扫码打印工具\扫码打印工具\Form1.cs

     文件      15038  2018-03-02 11:52  扫码打印工具\扫码打印工具\Form1.Designer.cs

     文件      20617  2018-03-02 11:52  扫码打印工具\扫码打印工具\Form1.resx

     文件       1970  2018-03-02 11:39  扫码打印工具\扫码打印工具\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6474  2018-03-02 13:57  扫码打印工具\扫码打印工具\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       4608  2018-02-27 17:32  扫码打印工具\扫码打印工具\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件         42  2019-04-04 15:42  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.csproj.CoreCompileInputs.cache

     文件        976  2018-03-02 11:39  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.csproj.FileListAbsolute.txt

     文件        975  2018-03-02 11:56  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.csproj.GenerateResource.Cache

     文件      30125  2019-04-04 15:42  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.csprojAssemblyReference.cache

     文件       6002  2018-03-02 11:46  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.csprojResolveAssemblyReference.cache

     文件      60928  2018-03-02 13:57  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.exe

     文件      10228  2018-03-02 11:56  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.Form1.resources

     文件      67072  2018-03-02 13:57  扫码打印工具\扫码打印工具\obj\x86\Debug\扫码打印工具.pdb

............此处省略29个文件信息

评论

共有 条评论