我试图将参数传递给我的应用程序中的存储过程,但我不知道我做错了什么.我收到一个错误
过程或函数'usp_getBorrowerDetails'需要参数'@BookID',这是未提供的.
虽然我正在路过,但我做了很多事情,但仍未找到解决办法.
这是我的代码:
IDataReader reader = null;
SqlCommand command = new SqlCommand();
try
{
SqlConnection connection = GetDBConnection();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = Constants.SP_BookBorrowerDetails;
command = new SqlCommand(command.CommandText, connection);
command.Parameters.AddWithValue("@BookID", bookID);
reader = base.ExecuteReader(command);
}
catch (System.Data.SqlClient.SqlException ex)
{
throw new Exception("Oops! Something went wrong.");
}
Run Code Online (Sandbox Code Playgroud)
以下是我的存储过程:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[usp_getBorrowerDetails]
@BookID INT
AS
SELECT
Name, Mobile, ReturnDate
FROM
BorrowerDetails
INNER JOIN
BookDetails ON BookDetails.CurrentBorrowerID = BorrowerDetails.ID
WHERE
BookDetails.BookID = @BookID
GO …Run Code Online (Sandbox Code Playgroud) 我在sql查询中面临单引号输入的问题.查询如下.
Dim query As String = "insert into users(comment) values ('" & txt_comment.Text & "')"
Run Code Online (Sandbox Code Playgroud)
它工作正常.但是,当用户在文本框中输入单个代码数据时,查询会崩溃.输入例如"henry's".有人想建议我该怎么办?提前致谢
我的阵列是 A = {2, 3, 4, 3, 4, 2, 4, 2, 4}
我需要一个数组 B,它在索引处存储数组 A 中出现i的次数i。
我想要一个返回的代码:
b[2] = 3
b[3] = 2
b[4] = 4
Run Code Online (Sandbox Code Playgroud)
请记住,如果在上述数组中A添加任何数字也应添加到结果数组中B。
如果有人在这方面帮助我,我将非常感激。
下面给出了我到目前为止所做的代码。
static void Main(string[] args)
{
int [] A = new int[4];
int [] B = new int [A.Length];
for (int i = 0; i > A.Length; i++)
{
B[A[i]] = B[i];
}
}
Run Code Online (Sandbox Code Playgroud)
我是编程新手。我有这个场景来写一个算法,我是第一次写这种类型的算法。