存储过程、事务、触发器。
一、调用带两个普通参数和一个输出参数的存储过程实现账号密码的验证。 存储过程为如下代码: create proc St_exam@adm varchar(50),@pwd varchar(50),@result int=1 outputasselect @result=COUNT(*) from Manage where Admin=@adm and Pwd=@pwdreturn @res
一、调用带两个普通参数和一个输出参数的存储过程实现账号密码的验证。
存储过程为如下代码:
create proc St_exam @adm varchar(50), @pwd varchar(50), @result int=1 output as select @result=COUNT(*) from Manage where Admin=@adm and Pwd=@pwd return @result
ASP.NET代码为如下:
protected void Page_Load(object sender, EventArgs e)
{
St_Proc(,);
}
public void St_Proc(string Adm, string Pwd)
{
SqlConnection conn = );
conn.Open();
SqlCommand cmd = , conn); // "St_exam" 为存储过程名
cmd.CommandType = CommandType.StoredProcedure;
//设置命令类型为存储过程
SqlParameter[] pa = { ,SqlDbType.VarChar), SqlParameter(,SqlDbType.VarChar),
SqlParameter(,SqlDbType.Int)};
pa[0].Value = Adm;
// 给参数赋值
pa[1].Value = Pwd;
pa[2].Direction = ParameterDirection.Output; //设置输出参数的输出方向 相当于获取输出参数的值
cmd.Parameters.AddRange(pa);
cmd.ExecuteNonQuery();
int result = int.Parse(cmd.Parameters[2].Value.ToString());
if (result==1)
{
Response.Write();
}
else
{
Response.Write();
}
}
,

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This website reported on March 7 that Dr. Zhou Yuefeng, President of Huawei's Data Storage Product Line, recently attended the MWC2024 conference and specifically demonstrated the new generation OceanStorArctic magnetoelectric storage solution designed for warm data (WarmData) and cold data (ColdData). Zhou Yuefeng, President of Huawei's data storage product line, released a series of innovative solutions. Image source: Huawei's official press release attached to this site is as follows: The cost of this solution is 20% lower than that of magnetic tape, and its power consumption is 90% lower than that of hard disks. According to foreign technology media blocksandfiles, a Huawei spokesperson also revealed information about the magnetoelectric storage solution: Huawei's magnetoelectronic disk (MED) is a major innovation in magnetic storage media. First generation ME

Vue3+TS+Vite development tips: How to encrypt and store data. With the rapid development of Internet technology, data security and privacy protection are becoming more and more important. In the Vue3+TS+Vite development environment, how to encrypt and store data is a problem that every developer needs to face. This article will introduce some common data encryption and storage techniques to help developers improve application security and user experience. 1. Data Encryption Front-end Data Encryption Front-end encryption is an important part of protecting data security. Commonly used

Lockwaittimeoutexceeded;tryrestartingtransaction - How to solve the MySQL error: transaction wait timeout. When using the MySQL database, you may sometimes encounter a common error: Lockwaittimeoutexceeded;tryrestartingtransaction. This error indicates that the transaction wait timeout. This error usually occurs when

MySQL transaction processing: the difference between automatic submission and manual submission. In the MySQL database, a transaction is a set of SQL statements. Either all executions are successful or all executions fail, ensuring the consistency and integrity of the data. In MySQL, transactions can be divided into automatic submission and manual submission. The difference lies in the timing of transaction submission and the scope of control over the transaction. The following will introduce the difference between automatic submission and manual submission in detail, and give specific code examples to illustrate. 1. Automatically submit in MySQL, if it is not displayed

Git is a fast, reliable, and adaptable distributed version control system. It is designed to support distributed, non-linear workflows, making it ideal for software development teams of all sizes. Each Git working directory is an independent repository with a complete history of all changes and the ability to track versions even without network access or a central server. GitHub is a Git repository hosted on the cloud that provides all the features of distributed revision control. GitHub is a Git repository hosted on the cloud. Unlike Git which is a CLI tool, GitHub has a web-based graphical user interface. It is used for version control, which involves collaborating with other developers and tracking changes to scripts and

How to write triggers in MySQL using PHP MySQL is a commonly used relational database management system, and PHP is a popular server-side scripting language. Using PHP to write triggers in MySQL can help us realize automated database operations. This article will introduce how to use PHP to write MySQL triggers and provide specific code examples. Before starting, make sure that MySQL and PHP have been installed and the corresponding database tables have been created. 1. Create PHP files and data

1. Introduction to PDO PDO is an extension library of PHP, which provides an object-oriented way to operate the database. PDO supports a variety of databases, including Mysql, postgresql, oracle, SQLServer, etc. PDO enables developers to use a unified API to operate different databases, which allows developers to easily switch between different databases. 2. PDO connects to the database. To use PDO to connect to the database, you first need to create a PDO object. The constructor of the PDO object receives three parameters: database type, host name, database username and password. For example, the following code creates an object that connects to a mysql database: $dsn="mysq

In Oracle database, you can use the CREATE TRIGGER statement to add triggers. A trigger is a database object that can define one or more events on a database table and automatically perform corresponding actions when the event occurs.
