使用ODBC向SQLServer存储过程传参数的方法
存储 过程 如下: CREATEPROCEDURETestSP @IDint AS RETURN@@ERROR GO 网上的例子都是用Sql的对象来传 参数 的,于是 使用 相同的格式写了代码,结果不能传 参数 ,代码如下: try { OdbcConnectionm_cConn=newOdbcConnection(); OdbcCommandm_cCommand=newO
存储过程如下:
CREATE PROCEDURE TestSP
@ID int
AS
RETURN @@ERROR
GO
网上的例子都是用Sql的对象来传参数的,于是使用相同的格式写了代码,结果不能传参数,代码如下:
try
{
OdbcConnection m_cConn = new OdbcConnection();
OdbcCommand m_cCommand = new OdbcCommand();
OdbcParameter cParam = new OdbcParameter("@ID", OdbcType.Int, 4);
m_cConn.ConnectionString = "Dsn=MySQLServer;trusted_connection=Yes;wsid=BINARYTREE;database=SimpleProjectDB";
m_cConn.Open();
m_cCommand.Connection = m_cConn;
m_cCommand.CommandText = "TestSP";
m_cCommand.CommandType = CommandType.StoredProcedure;
m_cCommand.Parameters.Add(cParam);
m_cCommand.ExecuteNonQuery();
}
catch (Exception cEx)
{
return;
}
上面的代码运行到m_cCommand.ExecuteNonQuery(); 时出异常,说是参数没有找到,问题出在CommandText属性的设置上。正确的格式应该如下:
m_cCommand.CommandText = "{CALL TestSP(?)}";

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

AI Hentai Generator
Generate AI Hentai for free.

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

For objects with the same name that already exist in the SQL Server database, the following steps need to be taken: Confirm the object type (table, view, stored procedure). IF NOT EXISTS can be used to skip creation if the object is empty. If the object has data, use a different name or modify the structure. Use DROP to delete existing objects (use caution, backup recommended). Check for schema changes to make sure there are no references to deleted or renamed objects.

The import steps are as follows: Copy the MDF file to SQL Server's data directory (usually C:\Program Files\Microsoft SQL Server\MSSQL\DATA). In SQL Server Management Studio (SSMS), open the database and select Attach. Click the Add button and select the MDF file. Confirm the database name and click the OK button.

Unfortunately, people often delete certain contacts accidentally for some reasons. WeChat is a widely used social software. To help users solve this problem, this article will introduce how to retrieve deleted contacts in a simple way. 1. Understand the WeChat contact deletion mechanism. This provides us with the possibility to retrieve deleted contacts. The contact deletion mechanism in WeChat removes them from the address book, but does not delete them completely. 2. Use WeChat’s built-in “Contact Book Recovery” function. WeChat provides “Contact Book Recovery” to save time and energy. Users can quickly retrieve previously deleted contacts through this function. 3. Enter the WeChat settings page and click the lower right corner, open the WeChat application "Me" and click the settings icon in the upper right corner to enter the settings page.

When the SQL Server service fails to start, here are some steps to resolve: Check the error log to determine the root cause. Make sure the service account has permission to start the service. Check whether dependency services are running. Disable antivirus software. Repair SQL Server installation. If the repair does not work, reinstall SQL Server.

To view the SQL Server port number: Open SSMS and connect to the server. Find the server name in Object Explorer, right-click it and select Properties. In the Connection tab, view the TCP Port field.

If you accidentally delete a SQL Server database, you can take the following steps to recover: stop database activity; back up log files; check database logs; recovery options: restore from backup; restore from transaction log; use DBCC CHECKDB; use third-party tools. Please back up your database regularly and enable transaction logging to prevent data loss.

If the SQL Server installation fails, you can clean it up by following these steps: Uninstall SQL Server Delete registry keys Delete files and folders Restart the computer

Mobile games have become an integral part of people's lives with the development of technology. It has attracted the attention of many players with its cute dragon egg image and interesting hatching process, and one of the games that has attracted much attention is the mobile version of Dragon Egg. To help players better cultivate and grow their own dragons in the game, this article will introduce to you how to hatch dragon eggs in the mobile version. 1. Choose the appropriate type of dragon egg. Players need to carefully choose the type of dragon egg that they like and suit themselves, based on the different types of dragon egg attributes and abilities provided in the game. 2. Upgrade the level of the incubation machine. Players need to improve the level of the incubation machine by completing tasks and collecting props. The level of the incubation machine determines the hatching speed and hatching success rate. 3. Collect the resources required for hatching. Players need to be in the game
