最新文章 (全部类别)
LinERP - 线联ERP - 模具管理及模具费操作流程
LinERP - 线联ERP - 客户运费管理及运费操作流程
LinERP - 线联ERP - 打开/关闭表格批量操作
C#高级功能:DevExpress复制表格到剪贴板粘贴到Excel
C# 清除IList所有对象包含指定的字符
C#高级功能:DevExpress复制表格到剪贴板粘贴到Excel
C# 清除IList所有对象包含指定的字符
C# 清除IList所有对象包含指定的字符
C# 清除IList所有对象包含指定的字符
C# 清除IList所有对象包含指定的字符
LinERP - 线联ERP - 表格列头通用弹出菜单
C#统计List<T>字符串属性长度(返回每个属性的最大长度)
网易云音乐ncm转mp3在线转换
NNOMS钮纽OMS系统安装操作手册
线联ERP - 快捷键
LinERP - 线联ERP - 物料管理
线联ERP - 实施与维护事项
线联ERP - 多帐套主数据关系表
线联ERP - 海康威视人脸考勤机设置固定IP、重启设备操作手册
线联ERP用户操作手册 - BOM管理
LinERP - 线联ERP - 公司内部编码客户、供应商对照表
LinERP - 线联ERP试用版下载
LinERP - 线联ERP客户服务
DevExpress V22.1 表格导出PDF支持中文
DevExportTool类 - DevExpress GridView 导出Excel文件通用类
解决DevExpress GridView导出XLS文件报错:Unable to cast object of type 'Windows.Win32.Messageld' to type 'System.IConvertible'
LinERP - 线联ERP - 物料类别操作说明
LinERP - 线联ERP主界面
LinERP - 线联ERP用户操作手册 - 系统登陆
LinERP - 线联ERP - 工具栏按钮列表
LinERP - 线联ERP - 数据查询/数据编辑操作手册
LinERP - 线联ERP - 状态栏操作说明
CMS修改主菜单类别编码CategoryNo
LinERP - 线联ERP简介
明细表支持批量操作删除
C# 图片按钮特效:鼠标移入变浅,移出恢复原样 (ImageButtonHover类)
C# 复制对象属性 CopyProperties扩展方法
线联ERP - 用户操作手册 - 系统初始化
线联ERP - 什么是主账套?
线联ERP - 用户操作手册 - 公司资料设置
C/S快速开发框架旗舰版CSFrameworkV6.0 - VS开发环境配置
修复BUG: CSFramework.EF框架 Remove<T>, RemoveWhere<T>
使用Xlight FTP文件服务器
印章公章在线免费制作
CSFrameworkV6.1旗舰版 - appsettings.json 配置文件增加参数
推荐:使用Photoshop制作ico图标
C#.NET格式化显示:数字末尾不显示0
SQL脚本:更新主表的完成标记FlagFinish=Y
FastReport.NET 设计器汉化&运行时汉化
VS2026/VS2022 关闭 “自动添加 using 命名空间”
.net敏捷开发,创造卓越

C#实现SQL查询分析器(C# Visual SQL Query Designer)


C#实现SQL查询分析器(C# Visual SQL Query Designer)


Introduction

This article describes the implementation of a QueryDesignerDialog class that allows users to create SQL queries based on a given OLEDB connection string.

The designer is similar to the ones found in database tools such as the SQL Server Management Studio and Microsoft Access. It allows end users to build SQL queries with support for sorting, grouping, and filtering.

The main limitation of the QueryDesignerDialog is that it does not parse existing SQL statements. This is a one-way tool; you can use it to create new queries, but not to edit existing ones. Also, it only supports OLEDB data sources, which includes SQL Server and Access. Future versions may address these limitations.

贴图图片


介绍

本文描述了QueryDesignerDialog类的实现, 通过OLEDB连接服务器后允许用户创建SQL查询语句.
该工具类似SQL Server Management Studio和Microsoft Access中的设计器. 甚至允许用户建立支持排序,分组和过滤的SQL语句.
QueryDesignerDialog是一个单向的工具, 主要限制是该类不能分析现有的SQL语句。 可以创建新的SQL查询但不能修改现有的SQL查询。
另外,它仅支持通过OLEDB连接的SQL Server和Access数据库.将来的版本会解决这些问题.

 

Background

The first version of the QueryDesignerDialog was written for use with a Report Designer application. I could not find a tool (free or commercial) to do the job the way I wanted, so I decided to write it myself. After that, I re-used it in a few other applications, and thought it might be useful to others as well.


背景

QueryDesignerDialog的第一个版本是为报表设计器应用程序(Report Designer application)开发的。我找不到一个能实现上述功能的工具(免费或商业化).
所以我决定自己开发,在此之后,该工具在其它程序中也有些应用,我希望它能帮助一些人.

 

Using the Code

The QueryDesignerDialog has two main properties:

  • ConnectionString: Gets or sets the OLEDB connection string used to retrieve the database schema with the list of tables, views, fields, and relations from which the query will be built.
  • SelectStatement: Gets the SQL statement designed by the user. For now, this is a read-only property. The dialog cannot be used to edit existing SQL statements. Perhaps this will be added in future versions.

The code snippet below shows how the QueryDesignerDialog is typically used. You assign it a connection string, show the dialog, and read back the SQL query:


使用方法

QueryDesignerDialog 有两个主要属性:
ConnectionString: 获取或设置OLEDB连接字符串,通过建立的SQL用来检索的表,视图,字段,关联的数据结构.
SelectStatement: 获取或设置用户输入的SQL语句,目前是只读属性,暂不能修改数据库中现有的SQL语句,也许将来的版本会实现此功能。

下面的代码片段展示QueryDesignerDialog典型应用。只需分配一个连接字符串然并显示对话框,然后读取你输入的SQL:


代码: 


// create the QueryDesignerDialog

using (var dlg = new QueryDesignerDialog())

{

  // set the connection string

  dlg.ConnectionString = ConnectionString;

 

  // show the dialog

  if (dlg.ShowDialog(this) == DialogResult.OK)

  {

    // get the new Sql query and do something with it

    string newSql = dlg.SelectStatement;

    DoSomething(newSql);

  }

}




贴图图片



This code invokes the "DataLink" dialog seen below:

打开"DataLink"对话框



// pick a new connection

void _btnConnPicker_Click(object sender, EventArgs e)

{

  // release mouse capture to avoid wait cursor

  _toolStrip.Capture = false;

 

  // get starting connection string

  // (if empty or no provider, start with SQL source as default)

  string connString = _cmbConnString.Text;

  if (string.IsNullOrEmpty(connString) ||

      connString.IndexOf("provider=", StringComparison.OrdinalIgnoreCase) < 0)

  {

    connString = "Provider=SQLOLEDB.1;";

  }

 

  // let user change it

  ConnectionString = OleDbConnString.EditConnectionString(this, connString);

}





贴图图片


www.csframework.com 翻译 原文转自codeproject,转载请注明出处.

原文:http://www.codeproject.com/KB/database/QueryDesigner.aspx

版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
C/S框架网
上一篇:C# ImageListView控件下载(源代码)
下一篇:动态SQL生成器(Dynamic SQL Generator)
评论列表

发表评论

评论内容
昵称:
关联文章

C#实现SQL查询分析器(C# Visual SQL Query Designer)
CSFrameworkV6旗舰版-实现查询功能 Query 方法
[下载]超好用高效率SQL客户端查询分析器(sqldbx)
C# WebApi将查询字符串RequestUri.Query解析转换为Hashtable
With语法实现SQL树结构数据查询(转)
业务窗体设计-实现查询功能
[原创]C# Access 模糊查询SQL语句
拼接SQL查询条件传入SP存储过程
C# 动态组合SQL脚本LIKE语句及查询参数防SQL注入攻击
Winform查询数据对话窗体与选择资料窗体实现|C/S框架网
Vue+Element-UI客户管理页面查询功能实现
LINQ+EF:Cannot use multiple context instances within a single query execution. Ensure the query uses a single context instance.
CSFramework.WebApiV3.Linq 语言集成查询
SQL2008多个查询条件分页查询脚本(原创)
SQL分页查询多种写法
Visual Studio 2019 (C#/.NET)安装教程
MiniFramework蝇量框架 Visual Studio解决方案
一.报表设计 (Report Designer)-FastReport报表设计-C/S快速开发框架-标准版V2.3
SQL 查询当前数据库的用户表或视图 sysobjects.xtype in (U,V)
SQL使用LIKE查询模糊匹配多个特殊标点符号的数据

热门标签
软件著作权登记证书 .NET .NET Reactor .NET5 .NET6 .NET7 .NET8 .NET9 .NETFramework AI编程 APP AspNetCore AuthV3 Auth-软件授权注册系统 Axios B/S B/S开发框架 B/S框架 BSFramework Bug Bug记录 C#加密解密 C#源码 C/S CHATGPT CMS系统 CodeGenerator CSFramework.DB CSFramework.EF CSFramework.License CSFrameworkV1学习版 CSFrameworkV2标准版 CSFrameworkV3高级版 CSFrameworkV4企业版 CSFrameworkV5旗舰版 CSFrameworkV6.0 CSFrameworkV6.1 CSFrameworkV6旗舰版 DAL数据访问层 DaMeng Database datalock DbFramework DeepSeek Demo教学 Demo实例 Demo下载 DevExpress教程 Docker Desktop DOM ECS服务器 EFCore EF框架 Element-UI EntityFramework ERP ES6 Excel FastReport GIT HR HR考勤系统 IDatabase IIS JavaScript LinERP LINQ MES MiniFramework MIS MSSQL MySql NavBarControl NETCore Node.JS NPM OMS Oracle资料 ORM PaaS POS PostgreSql Promise API PSD QMS RedGet Redis RSA SAP Schema SEO SEO文章 SQL SQLConnector SQLite SqlServer Swagger TMS系统 Token令牌 VS2022 VSCode VS升级 VUE WCF WebApi WebApi NETCore WebApi框架 WEB开发框架 Windows服务 Winform 开发框架 Winform 开发平台 WinFramework Workflow工作流 Workflow流程引擎 XtraReport 安装环境 版本区别 报表 备份还原 踩坑日记 操作手册 成本核算系统 达梦数据库 代码生成器 电子线材ERP 迭代开发记录 功能介绍 官方软件下载 国际化 海康威视考勤 基础资料窗体 架构设计 角色权限 开发sce 开发工具 开发技巧 开发教程 开发框架 开发平台 开发指南 客户案例 快速搭站系统 快速开发平台 框架升级 毛衫行业ERP 秘钥 密钥 企业网络维护 权限设计 软件报价 软件测试报告 软件加壳 软件简介 软件开发框架 软件开发平台 软件开发文档 软件授权 软件授权注册系统 软件体系架构 软件下载 软件著作权登记证书 软著证书 三层架构 设计模式 生成代码 实用小技巧 视频下载 收钱音箱 数据锁 数据同步 塑木地板行业ERP 推荐软件 微信小程序 未解决问题 文档下载 喜鹊ERP 喜鹊软件 系统对接 线联ERP 详细设计说明书 新功能 信创 行政区域数据库 需求分析 疑难杂症 蝇量级框架 蝇量框架 用户管理 用户开发手册 用户控件 在线软件 在线支付 纸箱ERP 智能语音收款机 自定义窗体 自定义组件 自动升级程序
联系我们
联系电话:13923396219(微信同号)
电子邮箱:23404761@qq.com
站长微信二维码
微信二维码