Hello,
I build some code, but I am still missing some part of the puzzle, what I am trying to do is how to submit a form that contains text boxes, checkboxes and dropdown list to a database in web form asp.net.
It gives me an error as well:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS7036: There is no argument given that corresponds to the required formal parameter 'sender' of 'Subpoena.Button1_Click(object, EventArgs)'
Source Error:
Thank you
public partial class Subpoena : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Create a list of month names
string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
// Add each month to the dropdown list
foreach (string frommonth in months)
{
fromMonth.Items.Add(new ListItem(frommonth, frommonth));
}
foreach (string tomonth in months)
{
toMonth.Items.Add(new ListItem(tomonth, tomonth));
}
// Create a list of Year
if (!IsPostBack)
{
fromYear.Items.Clear();
fromYear.Items.Add("From Year");
var currentYear = DateTime.Today.Year;
for (int i = 7; i >= 0; i--)
{
// Now just add an entry that's the current year minus the counter
fromYear.Items.Add((currentYear - i).ToString());
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
// Extract values from textboxes
int memberacct = int.Parse(memberAcct.Text);
string membername = memberName.Text;
duedate.Text = DateTime.Now.AddDays(3).ToString("dd/MM/yyyy");
// Extract values from dropdownlist
string frommonth = fromMonth.SelectedValue;
string tomonth = toMonth.SelectedValue;
// Insert the data into the database
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ToString()))
{
connection.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO Main (@memberNumber,@memberName, @fromMonth, @fromYear, @toMonth, @toYear, @dueDate)", connection);
cmd.Parameters.AddWithValue("@memberNumber", memberacct);
cmd.Parameters.AddWithValue("@memeberName", membername);
cmd.Parameters.AddWithValue("@fromMonth", frommonth);
cmd.Parameters.AddWithValue("@fromYear", fromYear);
cmd.Parameters.AddWithValue("@toMonth", tomonth);
cmd.Parameters.AddWithValue("@toYear", toYear);
cmd.Parameters.AddWithValue("@dueDate", duedate);
cmd.Parameters.AddWithValue("@imageData", toMonth);
cmd.ExecuteNonQuery();
connection.Close();
Response.Write("Image has been Added");
}
}
}
SUBPOENA FORM

Jignesh KumarPosted Nov 20, 2024, 4:06 AM
Hello,
Just remove () from your button onClick="Button1_Click()"
Replace Below line
With this,
Ivonne AspilcuetaPosted Nov 25, 2024, 7:20 PM
Created a store procedure. Thank you.