Jump to content


Check out our Community Blogs

percis

Member Since 23 Jun 2012
Offline Last Active May 27 2014 01:02 AM
-----

Topics I've Started

SELECT statement

02 August 2012 - 08:04 PM

if (radioButton3.Checked == true)
{
conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\FYP_Prgms\FYP_ 31\BatterySelectionDatabase1.accdb");
dt = new DataTable();
SDA = new OleDbDataAdapter("SELECT * FROM BatterySelection where Discharge <= " + int.Parse(txt_DischargeRate.Text) + " AND Amp >=" + int.Parse (txt_Amp.Text), conn);
SDA.Fill(dt);
dataGridView1.DataSource = dt;
}
Battery models are being displayed on the datagrid view when it meets the condition as shown in the coding.
if there's a situation, no data displayed in the datagrid view. As the battery models do not meet the conditions.
In this situation, how do i modify the SELECT statement in the same event handler and display a msg as " No battery model found".

Delete The Data From The Row Of Datagridview

30 July 2012 - 12:45 AM


OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Student\Desktop\Database 4.accdb");
conn.Open();
string vsql = String.Format(" insert into [Memo] values ({0},'{1}','{2}','{3}')", int.Parse(textBox1.Text), textBox2.Text,textBox3.Text,textBox5.Text);
//textBox1 for Hours , textBox2 for Model ,textbox3 for Address
OleDbCommand com = new OleDbCommand(vsql, conn);
com.ExecuteNonQuery();
MessageBox.Show("Data stored successfully");
com.Dispose();
i'm able to save data into the datagrid view as above-mentioned code.

but i'm unable delete any selected row.

hw should i write the code to delete any selected row (i.e. clicking on the row) of the datagridview followed by clicking on the "delete" btn?

Changing Picture In The Picturebox At A Certain Interval

26 July 2012 - 09:10 PM

Hi,

I have a qn : change 5 pictures being displayed in the picturebox for 3 sec.
is it possible to show once the prgm is debugged but nt by clicking on a button.

code?

where i have to save the pictures to retrieve? i don't get difficulty even i run the prgm on any computer.

Thanks!

This post has been promoted to an article

Display Value In The Textbox With If Condition

25 July 2012 - 09:43 PM

private void button1_Click_2(object sender, EventArgs e)
      {
         //if (checkBox2.Checked == false &amp;&amp; checkBox3.Checked == false &amp;&amp; checkBox4.Checked == false &amp;&amp; checkBox5.Checked == false &amp;&amp; checkBox6.Checked == false)
         //{
         //   MessageBox.Show(" Please enter the user requirements");
         //}

         double dblTotalDemand, dblBatteryCapacity;
         if (txt_AhDemand.Text != "" &amp;&amp; cbb_NumberofDaysofAutonomy.Text != "" &amp;&amp; cbb_DepthofDischarge.Text != "")
         {
            dblTotalDemand = Convert.ToDouble(txt_AhDemand.Text) * Convert.ToDouble(cbb_NumberofDaysofAutonomy.Text);
            dblBatteryCapacity = dblTotalDemand / Convert.ToDouble(cbb_DepthofDischarge.Text);
            txt_BatteryCapacity.Text = dblBatteryCapacity.ToString("#");
         }
         double dblDischargeRate;
         if (txt_BatteryCapacity.Text != "" &amp;&amp; txt_DischargeCurrent.Text != "")
         {
            dblDischargeRate = (Convert.ToDouble(txt_BatteryCapacity.Text) / Convert.ToDouble(txt_DischargeCurrent.Text));
            txt_DischargeRate.Text = dblDischargeRate.ToString("#");
         }
         MessageBox.Show("Hence you need a battery that has a Capacity of " + txt_BatteryCapacity.Text + " Ah; at Discharge Rate of " + txt_DischargeRate.Text + " Hours", "BatterySizing", MessageBoxButtons.OK, MessageBoxIcon.Information);
      }

private void textBox2_TextChanged(object sender, EventArgs e)
      {
      }

from cbb_DepthofDiscaharge i can select either 0.8, 0.5, 0.3 or 0.1.
my qn is : when i select 0.8 i want to display 1500 on textBox2
when i select 0.5 i want to display 2500 on textBox2
when i select 0.3 i want to display 3300 on textBox2
when i select 0.1 i want to display 4000 on textBox2

how to write the code for cbb_DepthofDischarge? pls..

Display Msg When Either One Of The Checkbox Not Checked

25 July 2012 - 07:28 PM

private void button1_Click_2(object sender, EventArgs e)
	  {
		 if (checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false && checkBox5.Checked = false && checkBox6.Checked = false)
		 {
		    MessageBox.Show(" Please enter the user requirements");
		 }
		
		 double dblTotalDemand, dblBatteryCapacity;
		 if (txt_AhDemand.Text != "" && cbb_NumberofDaysofAutonomy.Text != "" && cbb_DepthofDischarge.Text != "")
		 {
		    dblTotalDemand = Convert.ToDouble(txt_AhDemand.Text) * Convert.ToDouble(cbb_NumberofDaysofAutonomy.Text);
		    dblBatteryCapacity = dblTotalDemand / Convert.ToDouble(cbb_DepthofDischarge.Text);
		    txt_BatteryCapacity.Text = dblBatteryCapacity.ToString("#");
		 }
		 double dblDischargeRate;
		 if (txt_BatteryCapacity.Text != "" && txt_DischargeCurrent.Text != "")
		 {
		    dblDischargeRate = (Convert.ToDouble(txt_BatteryCapacity.Text) / Convert.ToDouble(txt_DischargeCurrent.Text));
		    txt_DischargeRate.Text = dblDischargeRate.ToString("#");
		 }
		 MessageBox.Show("Hence you need a battery that has a capacity of " + txt_BatteryCapacity.Text + " Ah; at discharge rate of " + txt_DischargeRate.Text+"Hours");
	  }


>>>>>>>>>>>>>>For this particular there is error as ' The left-hand side of an assignment must be a variable, property or indexer.
		 if (checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false && checkBox5.Checked = false && checkBox6.Checked = false)
		 {
		    MessageBox.Show(" Please enter the user requirements");
		 }

1) how to correct?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download