资源简介

达梦数据库连接。

资源截图

代码片段和文件信息

using Dm;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text;

namespace ConsoleApp2
{
    public class DHHelper
    {


        /// 

        /// 获得数据库链接

        /// 


        /// 

        public DmConnection GetConn()

        {
            
            string strconn = “server=localhost;User Id=SYSDBA;PWD=sa;port=5236“;

            DmConnection conn = new DmConnection(strconn);

            conn.Open();

            return conn;

        }



        //插入数据

        public void Insert()

        {

            DmConnection conn = GetConn();

            string strCmd = “Insert into  SYSDBA.Users(NameSexAge)values(‘xumingxiang‘‘man‘25)“;

            DmCommand cmd = new DmCommand(strCmd conn);

            int effect = cmd.ExecuteNonQuery();

            conn.Close();//关闭数据库链接

        }



        /// 

        /// 删除数据

        /// 


        public void Update()

        {

            DmConnection conn = GetConn();

            string strCmd = “update  SYSDBA.Users set Age=100 where Id=1“;

            DmCommand cmd = new DmCommand(strCmd conn);

            int effect = cmd.ExecuteNonQuery();

            conn.Close();

        }



        /// 

        /// 删除数据

        /// 


        public void Delete()

        {

            DmConnection conn = GetConn();

            string strCmd = “delete from  SYSDBA.Users  where Id=1“;

            DmCommand cmd = new DmCommand(strCmd conn);

            int effect = cmd.ExecuteNonQuery();

            conn.Close();

        }



        /// 

        /// 用ExecuteReader查询数据

        /// 


        public void QueryByExecuteReader()
        {
            DmConnection conn = GetConn();
            string strCmd = “select * from  DBO.Model_Content “;
            DmCommand cmd = new DmCommand(strCmd conn);
            DmDataReader dr = cmd.ExecuteReader();
            int id;
            string name;
            string sex;
            int age;
            while (dr.Read())
            {
                id = dr.GetInt32(0);
                name = dr.GetString(1);
                sex = dr.GetString(2);
                age = dr.GetInt32(3);
            }
        }





        /// 

        ///用DataAdapter 查询数据,返回DataSet

        /// 


        public DataSet QueryByDataAdapter()
        {
            DmConnection conn = GetConn();
            string strCmd = “select * from  GH.Model_Content “;
            DmDataAdapter da = new DmDataAdapter(strCmd conn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            return ds;
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-10-10 16:14  ConsoleApp2\
     目录           0  2019-10-10 16:14  ConsoleApp2\.vs\
     目录           0  2019-10-11 10:16  ConsoleApp2\.vs\ConsoleApp2\
     目录           0  2019-10-11 10:16  ConsoleApp2\.vs\ConsoleApp2\DesignTimeBuild\
     文件     1205792  2020-01-13 09:42  ConsoleApp2\.vs\ConsoleApp2\DesignTimeBuild\.dtbcache
     文件       97428  2020-09-03 16:25  ConsoleApp2\.vs\ConsoleApp2\DesignTimeBuild\.dtbcache.v2
     目录           0  2019-10-10 16:14  ConsoleApp2\.vs\ConsoleApp2\v15\
     文件      104960  2020-01-13 09:42  ConsoleApp2\.vs\ConsoleApp2\v15\.suo
     目录           0  2019-10-10 16:14  ConsoleApp2\.vs\ConsoleApp2\v15\Server\
     目录           0  2020-01-13 09:42  ConsoleApp2\.vs\ConsoleApp2\v15\Server\sqlite3\
     文件           0  2019-10-10 16:14  ConsoleApp2\.vs\ConsoleApp2\v15\Server\sqlite3\db.lock
     文件     1286144  2020-01-13 09:42  ConsoleApp2\.vs\ConsoleApp2\v15\Server\sqlite3\storage.ide
     目录           0  2020-09-03 16:21  ConsoleApp2\.vs\ConsoleApp2\v16\
     文件      104960  2020-09-03 16:25  ConsoleApp2\.vs\ConsoleApp2\v16\.suo
     目录           0  2020-09-03 16:24  ConsoleApp2\ConsoleApp2\
     文件        1131  2019-10-10 16:14  ConsoleApp2\ConsoleApp2.sln
     目录           0  2019-10-10 16:14  ConsoleApp2\ConsoleApp2\bin\
     目录           0  2019-10-11 11:09  ConsoleApp2\ConsoleApp2\bin\Debug\
     目录           0  2019-10-11 11:13  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\
     文件        1069  2019-10-11 11:13  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\ConsoleApp2.deps.json
     文件        6144  2019-11-18 16:10  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\ConsoleApp2.dll
     文件        1328  2019-11-18 16:10  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\ConsoleApp2.pdb
     文件         262  2019-10-11 11:13  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\ConsoleApp2.runtimeconfig.dev.json
     文件         154  2019-10-11 11:13  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\ConsoleApp2.runtimeconfig.json
     文件      379904  2019-10-10 08:33  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\DmProvider.dll
     目录           0  2019-10-11 11:13  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\en\
     文件       20480  2019-10-10 08:33  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\en\DmProvider.resources.dll
     目录           0  2019-10-11 11:13  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\zh-CN\
     文件       21504  2019-10-10 08:33  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.1\zh-CN\DmProvider.resources.dll
     目录           0  2019-10-10 16:15  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.2\
     文件        9284  2019-10-11 11:08  ConsoleApp2\ConsoleApp2\bin\Debug\netcoreapp2.2\ConsoleApp2.deps.json
............此处省略41个文件信息

评论

共有 条评论