且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在客户端PC上运行Windows Form SQL Server Express基于程序

更新时间:2022-11-25 13:36:44

string con_string = @"Data Source=.\SQLEXPRESS2014;Initial Catalog=hamkar_Vendor1;Integrated Security=True";


此路径.\ SQLEXPRESS2014"是本地存储,您需要将其更改为目标服务器.


This path ''.\SQLEXPRESS2014'' is to local storage, you need to change it to target server.

Getdata("select * from vendor where lower(Company_Name) like '%" + searchtxt.Text.ToLower() + "%'");


为什么要以此作为参数的用法?

不是您的问题的解决方案,而是您遇到的另一个问题.
切勿通过串联字符串来构建SQL查询.迟早,您将使用用户输入来执行此操作,这将打开一个名为"SQL注入"的漏洞的大门,这对您的数据库很危险,并且容易出错.
名称中的单引号会导致程序崩溃.如果用户输入的名称如"Brian O" Conner"可能会使您的应用程序崩溃,则这是一个SQL注入漏洞,而崩溃是最少的问题,这是恶意的用户输入,并且使用所有凭据将其提升为SQL命令.
SQL注入-Wikipedia [ ^ ]
SQL注入 [ ^ ]
SQL注入攻击示例 [ PHP:SQL注入-手册 [ SQL注入预防作弊表-OWASP [


Why are doing this as your about usage of parameters?

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O''Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]