Click here to Skip to main content
16,007,687 members

Comments by akminder (Top 6 by date)

akminder 24-Feb-12 2:51am View    
<pre lang="c#"> SqlConnection con;
// SqlCommand com;
String message;
con = new SqlConnection(@"Data Source=AKMINDER-PC\SQLEXPRESS;Initial Catalog=elin appliances(Comaker of PHILIPS);Integrated Security=true");
SqlCommand com = new SqlCommand();
message = "Select product_id, product_name from product_info";
con.Open();
DataSet DS = new DataSet();
SqlDataAdapter DA = new SqlDataAdapter();

DA.SelectCommand = new SqlCommand(message, con);
// com.ExecuteNonQuery();

DA.Fill(DS);
con.Close();
if (DS.Tables[0].Rows.Count > 0)
{
combo1.DataSource = DS.Tables[0];
combo1.DisplayMember = "product_name";
combo1.ValueMember = "product_id";

//combo1.Items.Insert(0, "--Select--");
}
else
{
lblMsg.Text = "No product found";
}

}
private void fillrawmaterialid(string proid)

{
SqlConnection con;
// SqlCommand com;
// String message;
con=new SqlConnection(@"Data Source=AKMINDER-PC\SQLEXPRESS;Initial Catalog=elin appliances(Comaker of PHILIPS);Integrated Security=true");
SqlCommand com = new SqlCommand();
//message = "Select Raw_Material_ID ,Raw_Material from Raw_Info where product_id='"+combo1.SelectedIndex+"'";
com.Connection = con;
com.CommandText = "Select Raw_Material_ID ,Raw_Material from Raw_Info where product_id='" + proid + "'";
com.Parameters.AddWithValue("@proid", proid);

DataSet DS = new DataSet();
SqlDataAdapter DA = new SqlDataAdapter();


DA.SelectCommand = com;
con.Open();

// com.ExecuteNonQuery();

DA.Fill(DS);
con.Close();
if (DS.Tables[0].Rows.Count > 0)
{
comborawid.DataSource = DS.Tables[0];
comborawid.DisplayMember = "Raw_Material";
comborawid.ValueMember = "Raw_Material_ID";

//combo1.Items.Insert(0, "--Select--");
}
else
{
lblMsg.Text = "No product found";
}
private void combo1_SelectedIndexChanged(object sender, EventArgs e)
{
string proid=(combo1.SelectedIndex.ToString());
fillrawmaterialid(proid);


}</pre>
Now with valuemember and Display member i am getting values in combo1 but i also want the list of raw material corressponding to selected index of Combo1 in cborawmaterial.
e.g if I select Product laptop in combo1_SelectedIndexChanged then only I should get specific raw material related to laptop not all rawmaterials which is stored in database
but i am getting whole list of raw material

do tell me about select query ...what change is need?
akminder 24-Feb-12 2:51am View    
<pre lang="c#"> SqlConnection con;
// SqlCommand com;
String message;
con = new SqlConnection(@"Data Source=AKMINDER-PC\SQLEXPRESS;Initial Catalog=elin appliances(Comaker of PHILIPS);Integrated Security=true");
SqlCommand com = new SqlCommand();
message = "Select product_id, product_name from product_info";
con.Open();
DataSet DS = new DataSet();
SqlDataAdapter DA = new SqlDataAdapter();

DA.SelectCommand = new SqlCommand(message, con);
// com.ExecuteNonQuery();

DA.Fill(DS);
con.Close();
if (DS.Tables[0].Rows.Count > 0)
{
combo1.DataSource = DS.Tables[0];
combo1.DisplayMember = "product_name";
combo1.ValueMember = "product_id";

//combo1.Items.Insert(0, "--Select--");
}
else
{
lblMsg.Text = "No product found";
}

}
private void fillrawmaterialid(string proid)

{
SqlConnection con;
// SqlCommand com;
// String message;
con=new SqlConnection(@"Data Source=AKMINDER-PC\SQLEXPRESS;Initial Catalog=elin appliances(Comaker of PHILIPS);Integrated Security=true");
SqlCommand com = new SqlCommand();
//message = "Select Raw_Material_ID ,Raw_Material from Raw_Info where product_id='"+combo1.SelectedIndex+"'";
com.Connection = con;
com.CommandText = "Select Raw_Material_ID ,Raw_Material from Raw_Info where product_id='" + proid + "'";
com.Parameters.AddWithValue("@proid", proid);

DataSet DS = new DataSet();
SqlDataAdapter DA = new SqlDataAdapter();


DA.SelectCommand = com;
con.Open();

// com.ExecuteNonQuery();

DA.Fill(DS);
con.Close();
if (DS.Tables[0].Rows.Count > 0)
{
comborawid.DataSource = DS.Tables[0];
comborawid.DisplayMember = "Raw_Material";
comborawid.ValueMember = "Raw_Material_ID";

//combo1.Items.Insert(0, "--Select--");
}
else
{
lblMsg.Text = "No product found";
}
private void combo1_SelectedIndexChanged(object sender, EventArgs e)
{
string proid=(combo1.SelectedIndex.ToString());
fillrawmaterialid(proid);


}</pre>
Now with valuemember and Display member i am getting values in combo1 but i also want the list of raw material corressponding to selected index of Combo1 in cborawmaterial.
e.g if I select Product laptop in combo1_SelectedIndexChanged then only I should get specific raw material related to laptop not all rawmaterials which is stored in database
but i am getting whole list of raw material

do tell me about select query ...what change is need?
akminder 24-Feb-12 2:51am View    
<pre lang="c#"> SqlConnection con;
// SqlCommand com;
String message;
con = new SqlConnection(@"Data Source=AKMINDER-PC\SQLEXPRESS;Initial Catalog=elin appliances(Comaker of PHILIPS);Integrated Security=true");
SqlCommand com = new SqlCommand();
message = "Select product_id, product_name from product_info";
con.Open();
DataSet DS = new DataSet();
SqlDataAdapter DA = new SqlDataAdapter();

DA.SelectCommand = new SqlCommand(message, con);
// com.ExecuteNonQuery();

DA.Fill(DS);
con.Close();
if (DS.Tables[0].Rows.Count > 0)
{
combo1.DataSource = DS.Tables[0];
combo1.DisplayMember = "product_name";
combo1.ValueMember = "product_id";

//combo1.Items.Insert(0, "--Select--");
}
else
{
lblMsg.Text = "No product found";
}

}
private void fillrawmaterialid(string proid)

{
SqlConnection con;
// SqlCommand com;
// String message;
con=new SqlConnection(@"Data Source=AKMINDER-PC\SQLEXPRESS;Initial Catalog=elin appliances(Comaker of PHILIPS);Integrated Security=true");
SqlCommand com = new SqlCommand();
//message = "Select Raw_Material_ID ,Raw_Material from Raw_Info where product_id='"+combo1.SelectedIndex+"'";
com.Connection = con;
com.CommandText = "Select Raw_Material_ID ,Raw_Material from Raw_Info where product_id='" + proid + "'";
com.Parameters.AddWithValue("@proid", proid);

DataSet DS = new DataSet();
SqlDataAdapter DA = new SqlDataAdapter();


DA.SelectCommand = com;
con.Open();

// com.ExecuteNonQuery();

DA.Fill(DS);
con.Close();
if (DS.Tables[0].Rows.Count > 0)
{
comborawid.DataSource = DS.Tables[0];
comborawid.DisplayMember = "Raw_Material";
comborawid.ValueMember = "Raw_Material_ID";

//combo1.Items.Insert(0, "--Select--");
}
else
{
lblMsg.Text = "No product found";
}
private void combo1_SelectedIndexChanged(object sender, EventArgs e)
{
string proid=(combo1.SelectedIndex.ToString());
fillrawmaterialid(proid);


}</pre>
Now with valuemember and Display member i am getting values in combo1 but i also want the list of raw material corressponding to selected index of Combo1 in cborawmaterial.
e.g if I select Product laptop in combo1_SelectedIndexChanged then only I should get specific raw material related to laptop not all rawmaterials which is stored in database
but i am getting whole list of raw material

do tell me about select query ...what change is need?
akminder 15-Feb-12 8:28am View    
yes it is a window application and i m displaying using label control
akminder 7-Feb-12 5:35am View    
I have installed again SQL server 2008 and Visual studio 2008 after that i am trying to install Service pack 1 of Visual studio but error occurs after the following steps described below:

1 Run the softwware.
2 Accepted licence conditions.
3 Selecting all the features and press next.While pressing next error occurs i.e
There are validation errors on this page.review error on the bottom of setup page,then provide valid parameters.
Error is there are no SQL Server instances or shared features that can be updated on this computer.

Pls suggest me some solution