Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
for login table

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
string insertQuery = "insert into login(username,empid)values (@username,@empid)";
SqlCommand cmd = new SqlCommand(insertQuery, conn);
cmd.Parameters.AddWithValue("@username", TextBox1.Text);
cmd.Parameters.AddWithValue("@empid", TextBox2.Text);

cmd.ExecuteNonQuery();

Session["username"] = TextBox1.Text;
Session["empid"] = TextBox2.Text;


conn.Close();

for table11 table
protected void Submit_Click(object sender, EventArgs e)
{
try
{


SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
string insertQuery = "insert into table11(ans,ans1,ans2,ans3,ans4,username,password) values (@ans,@ans1,@ans2,@ans3,@ans4,@username,@password)";
SqlCommand cmd = new SqlCommand(insertQuery, conn);
cmd.Parameters.AddWithValue("ans", RadioButtonList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("ans1", RadioButtonList2.SelectedItem.Text);
cmd.Parameters.AddWithValue("ans2", RadioButtonList3.SelectedItem.Text);
cmd.Parameters.AddWithValue("ans3", RadioButtonList4.SelectedItem.Text);
cmd.Parameters.AddWithValue("ans4", RadioButtonList5.SelectedItem.Text);
cmd.Parameters.AddWithValue("username", Session["username"].ToString());
cmd.Parameters.AddWithValue("empid", Session["empid"].ToString());

cmd.ExecuteNonQuery();

Response.Write("You Submitted Sucessfully!");


conn.Close();
}
catch (Exception ex)
{

}

}

What I have tried:

for username I have made table login.
and in table11 I want the username and empid using sessions
I'm unable to store username, empid into the table .
please provide me with the correct code to store the username and empid into table 11
Posted
Updated 16-Jan-18 1:54am

No one is going to write code for you.You have to first design a page in ASP.net then you need to write button click,page load etc..Then business logic and data access layers. One question Does your session keeps the values.If you are using a single page Session is not required you can do the same with View state.Also put a break point and check if you are getting the values from text box or not.Also you can declare variables and store the text box values to pass in your sql Insert query.However Code project does have some great articles which can help you to design a survey page.

Survey/Polling System Using RadioButton List[^]
 
Share this answer
 
Please Refer the link You will get exact solution

Creating a Poll System in C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900