我想将下面的 C# 代码从普通 SQL 更改为存储过程,但它总是在它们所在的列上显示错误Invalid Column
。存储过程有什么问题?
CREATE PROCEDURE [dbo].[usp_AdminRegPage1]
(@VendorId VARCHAR)
AS
BEGIN
SET NOCOUNT ON;
SELECT WorksPackage,MajorWorks FROM dbo.RegPage1 WHERE Vendor_Id = @VendorId;
END
protected void DisplayRecord()
{
SqlConnection SqlCon = new SqlConnection(GetConnectionString());
string sql = "SELECT WorksPackage,MajorWorks from RegPage1
WHERE Vendor_ID='"+lblPage1ID.Text+"'";
var da = new SqlDataAdapter(sql, SqlCon);
var ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
txtMajorPackages.Text = ds.Tables[0].Rows[0]["WorksPackage"].ToString();
txtRegP1Works.Text = ds.Tables[0].Rows[0]["MajorWorks"].ToString();
}
}