如何解决这个错误?必须声明标量变量“@cname”。 [英] How to solve this error? Must declare the scalar variable "@cname".

查看:121
本文介绍了如何解决这个错误?必须声明标量变量“@cname”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用gridview我试图更新和删除asp.net网页表格中的数据库表格

但是我收到这样的错误 -

Using gridview i am trying to update and delete database table in asp.net web form
but i am getting errors like this-

Must declare the scalar variable "@cname".





和错误在这里 -



and Error is here-

SELECT * FROM [Coaches_db]" UpdateCommand="UPDATE [Coaches_db] set [FullName]=@cname,[Gender]=@Gender,[AGE]=@age,[Contacts]=@contact,[EmailID]=@email,[Experiance]=@Expr,[JoiningDate]=@joindate,[Coach_Level]=@positions,[Salery]=@salerys,[LeavingDate]=@Leavedate where [cid]=@cid"





我尝试过:





What I have tried:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:KARATE-ACADEMYConnectionString %>"
                   SelectCommand="SELECT * FROM [Coaches_db]" UpdateCommand="UPDATE [Coaches_db] set [FullName]=@cname,[Gender]=@Gender,[AGE]=@age,[Contacts]=@contact,[EmailID]=@email,[Experiance]=@Expr,[JoiningDate]=@joindate,[Coach_Level]=@positions,[Salery]=@salerys,[LeavingDate]=@Leavedate where [cid]=@cid"
                   DeleteCommand="DELETE"></asp:SqlDataSource>

<pre lang="HTML"><pre><pre lang="c#"><pre lang="c#">

推荐答案

ConnectionStrings:KARATE-ACADEMYConnectionString%>
SelectCommand =SELECT * FROM [Coaches_db]UpdateCommand = UPDATE [Coaches_db]设置[FullName] = @ cname,[Gender] = @ Gender,[AGE] = @ age,[Contacts] = @ contact,[EmailID] = @ email,[Experiance] = @Expr,[JoiningDate ] = @ joindate,[Coach_Level] = @ positions,[Salery] = @ salerys,[LeavingDate] = @ Leavedate,其中[cid] = @ cid
DeleteCommand =DELETE>< / asp:SqlDataSource> ;
ConnectionStrings:KARATE-ACADEMYConnectionString %>" SelectCommand="SELECT * FROM [Coaches_db]" UpdateCommand="UPDATE [Coaches_db] set [FullName]=@cname,[Gender]=@Gender,[AGE]=@age,[Contacts]=@contact,[EmailID]=@email,[Experiance]=@Expr,[JoiningDate]=@joindate,[Coach_Level]=@positions,[Salery]=@salerys,[LeavingDate]=@Leavedate where [cid]=@cid" DeleteCommand="DELETE"></asp:SqlDataSource>

<pre lang="HTML"><pre><pre lang="c#"><pre lang="c#">


你是编写参数化查询但您实际上没有声明任何SqlParameter源。 SqlParameter Class(System.Data.SqlClient)| Microsoft Docs [ ^ ]
You are writing parameterized queries but you haven't actually declared any SqlParameter sources. SqlParameter Class (System.Data.SqlClient) | Microsoft Docs[^]


这篇关于如何解决这个错误?必须声明标量变量“@cname”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆