过程或函数'SearchCustomer'需要参数'@CustomeID',它未提供。 [英] Procedure or function 'SearchCustomer' expects parameter '@CustomeID', which was not supplied.
本文介绍了过程或函数'SearchCustomer'需要参数'@CustomeID',它未提供。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DAL代码
DAL Code
public void SearchCustomer(int CustomerID)
{
try
{
conn = new SqlConnection(GlobalVariable.ConnectionString);
cmd = new SqlCommand();
cmd.CommandText = "[dbo].[SearchCustomer]";
cmd.CommandTimeout = 0;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = conn;
cmd.Parameters.Add("@CustomerID", SqlDbType.Int, 20).Value = CustomerID;
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows == true)
{
dr.Read();
string CustomerName = dr["CustomerName"].ToString();
string ShopName = dr["ShopName"].ToString();
string ShopAddress = dr["ShopAddress"].ToString();
string WorkPhone = dr["WorkPhone"].ToString();
string CellPhone = dr["CellPhone"].ToString();
string BusinessType = dr["BusinessType"].ToString();
dr.Close();
}
}
catch (SqlException)
{
throw;
}
}
BAL代码
BAL Code
public void SearchCustomer(string CustomerID)
{
DataAccess.CustomerDLL obj = new DataAccess.CustomerDLL();
obj.SearchCustomer(Convert.ToInt32(CustomerID));
}
表示层
Presentation layer
private void txtCustomerID_Leave(object sender, EventArgs e)
{
if (txtCustomerID.Text.Length == 0)
{
return;
}
Business.CustomerBLL obj = new Business.CustomerBLL();
string CustomerID = txtCustomerID.Text;
string CustomerName = txtCustomerName.Text;
string ShopName = txtShopName.Text;
string ShopAddress = txtShopAddress.Text;
string WorkPhone = txtWorkPhone.Text;
string CellPhone = txtCellPhone.Text;
string BusinessType = cmbBusinessType.Text;
obj.SearchCustomer(CustomerID);
}
程序
Procedure
USE [Diamond]
GO
/****** Object: StoredProcedure [dbo].[SearchCustomer] Script Date: 01/27/2013 02:25:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[SearchCustomer]
@CustomeID int
AS
BEGIN
SET NOCOUNT ON;
Select * From CustomerInfo Where (CustomerID = @CustomeID)
END
推荐答案
非常明显。
您正在通过 CustomerID
cmd.Parameters.Add(@ CustomerID,SqlDbType.Int,20).Value = CustomerID;
存储时程序有拼写错误并且需要 CustomeID
Pretty obvious.
You are passing CustomerID
cmd.Parameters.Add("@CustomerID", SqlDbType.Int, 20).Value = CustomerID;
while stored procedure has a typo and expects CustomeID
ALTER PROCEDURE [dbo].[SearchCustomer]
@CustomeID int
AS
建议:注意拼写检查提示。
Advise: pay attention to spellchecker hints.
这篇关于过程或函数'SearchCustomer'需要参数'@CustomeID',它未提供。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文