Hi Everyone
I have used a drop down and a label. I want on the selection of the drop down data should be viewed on label.
<code>ex: if user select value from drop down (Apple) so on label it should print (50 per KG)</code>
i have written the code for this query but i am not getting proper answer please check the code and let me know where is the error please
private void cmddiscount_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection cnn1 = new SqlConnection(@"Server=NGENIOUS-WSSDEV\SQLEXPRESS;Database=MIC;Trusted_Connection= True")
cnn1.Open()
DataSet da = new DataSet()
SqlDataAdapter sda = new SqlDataAdapter("select flat,percentile from discount where flat='Per Unit' and percentile='On MRP' ", cnn1)
sda.Fill(da, "discount")
int i = 0
for (i = 0
{
string x = da.Tables[0].Rows[0][i].ToString()
if (cmddiscount.SelectedItem.ToString() == "percentile")
{
label5.Text = x
}
else
{
if (cmddiscount.SelectedItem.ToString() == "flat")
{
label5.Text = x
}
}
<br />
i am getting one same name display on the selection of any from combo box
Data should come from sqldata and I can't use join because there is no relationship between the two tables. Is there any other suggestion on how I can do this ?
2) i am using data grid view in that i want that user should typed manually address and then click on submit then data should save in sql server
the code i have written is giving me error
SqlConnection con = new SqlConnection(@"Server=NGENIOUS-WSSDEV\SQLEXPRESS;Database=MIC;Trusted_Connection= True");
con.Open();
SqlCommand cmd = new SqlCommand("insert into clientwiseproductwise(productcategory,discounttype,scount,Dfactor)values ('" + productcategoryDataGridViewTextBoxColumn + "','" + discounttypeDataGridViewTextBoxColumn + "','" + DiscountValue + "','" + dfactorDataGridViewTextBoxColumn + "')", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Data Successfully Submitted");
if in insert statement i put @productcategory then it is telling me must declare variable
if i remove @
then the error is
String or binary data would be truncated.
The statement has been terminated.
please help me As soon as possible please