Click here to Skip to main content
15,797,330 members

Comments by SuperJWP (Top 3 by date)

SuperJWP 6-May-20 10:03am View    
The employee use multiple applications, therefore, i cannot create multiple rows for one user with all relevant applications the employee use.
SuperJWP 29-Apr-20 12:34pm View    
What do you mean, can you be more clearer please
SuperJWP 30-Nov-18 2:25am View    
I am having issues with my code , when i submit the data

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Linq;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Configuration;
using System.Dynamic;
using System.Data.SqlClient;
using System.Data;

public partial class NewEmployeeRequestForm : System.Web.UI.Page
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection();

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)
SqlConnection con = new SqlConnection(@"Data Source=SH-JASONK\DEV;Initial Catalog=EmployeeRegistration;Integrated Security=True");

SqlCommand cmd = new SqlCommand("insert into Employees values(@FirstName, @LastName, @Email, @Gender, @Phone, @StartDate, @Company, @Department, @Applications, @Requestedby)", con);

cmd.Parameters.AddWithValue("@FirstName", FirstName.Text);
cmd.Parameters.AddWithValue("@LastName", LastName.Text);
cmd.Parameters.AddWithValue("@Email", Email.Text);
cmd.Parameters.AddWithValue("@Gender", RadioButtonList1.SelectedValue);
cmd.Parameters.AddWithValue("@Phone", Phone.Text);
cmd.Parameters.AddWithValue("@StartDate", StartDate.Text);
cmd.Parameters.AddWithValue("@Company", Company.SelectedValue);
cmd.Parameters.AddWithValue("@Department", Departments.SelectedValue);
cmd.Parameters.AddWithValue("@Applicatons", CheckBoxList1.SelectedValue);
cmd.Parameters.AddWithValue("@Devices", RadioButtonList.SelectedValue);




The Error i receive is :

Must declare the scalar variable "@Applications".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@Applications".

Source Error:

Line 42: cmd.Parameters.AddWithValue("@Applicatons", CheckBoxList1.SelectedValue);
Line 43: cmd.Parameters.AddWithValue("@Devices", RadioButtonList.SelectedValue);
Line 44: cmd.ExecuteNonQuery();
Line 45: con.Close();
Line 46: