Почему эта ошибка показана параметризованного запроса '(@дата типа datetime, @идентификатор имеет тип nvarchar(4000), @идентификатор_курса тип nvarchar(1), @statu е.' ожидает, что параметр '@ИД', который не был указан.
why this error shown The parameterized query '(@date datetime,@id nvarchar(4000),@course_Id nvarchar(1),@statu' expects the parameter '@id', which was not supplied.
Что я уже пробовал:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="WebForm24.aspx.vb" Inherits="assigment.WebForm24" %> <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> <div class="container"> <div class="row"> <div class="col-lg-12"> <h2>subscribe for course</h2> </div> </div> </div> <asp:Label ID="Label1" runat="server" Text="select a course"></asp:Label> <asp:DropDownList ID="ddlcourse" runat="server"></asp:DropDownList> <asp:Button ID="subscribebtn" runat="server" Text="subscribe" OnClick="subscribebtn_Click" /> <asp:Label ID="Lblmsg" runat="server" Text=""></asp:Label> </asp:Content> code behind Imports System Imports System.Web Imports System.Data Imports System.Data.SqlClient Imports System.Web.Configuration Imports System.Configuration Imports System.Text Imports System.IO Imports System.Security.Cryptography Imports System.Net.Mail Public Class WebForm24 Inherits System.Web.UI.Page Private ReadOnly _conString As String Public Sub New() _conString = WebConfigurationManager.ConnectionStrings("learningSystem").ConnectionString End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim con As New SqlConnection(_conString) Dim cmd As New SqlCommand() cmd.CommandType = CommandType.Text cmd.CommandText = "Select * from tblcourse" cmd.Connection = con con.Open() ddlcourse.DataSource = cmd.ExecuteReader() ddlcourse.DataTextField = "course_name" ddlcourse.DataValueField = "course_Id" ddlcourse.DataBind() con.Close() Dim li As New ListItem("select a course", "-1") ddlcourse.Items.Insert(0, li) End If End Sub Protected Sub subscribebtn_Click(sender As Object, e As EventArgs) Dim con As New SqlConnection(_conString) Dim cmd As New SqlCommand() cmd.Connection = con cmd.CommandType = CommandType.Text con.Open() cmd.CommandText = "insert into tblsubscription (date,Id,course_Id,status)values(@date,@id,@course_Id,@status)" cmd.Parameters.AddWithValue("@date", DateTime.Now) cmd.Parameters.AddWithValue("@id", Session("S_uid")) cmd.Parameters.AddWithValue("@course_Id", ddlcourse.SelectedValue) cmd.Parameters.AddWithValue("@status", 0) cmd.ExecuteNonQuery() con.Close() Lblmsg.Text = "your subscription has been sent" End Sub End Class