|
Nobody's going to take the time to explain that to you. You'll have to take the trouble to get your head around it yourself. Here's a start: Object-Oriented Programming Principles[^] (video).
/ravi
|
|
|
|
|
|
This keeps appearing my in program everytime I run it, I really do not understand this
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
the error appears to be where it says "new Form1" then appears to say that Input String was in the incorrect format
|
|
|
|
|
That's standard boilerplate code to start a Windows Forms app and has absolutely nothing to do with your error.
It appears as though you have a problem converting a string to some data type, but there isn't enough information to narrow it down beyond this.
|
|
|
|
|
Don't tell us what the error appears to say; copy the full details of the exception and post that. There's a link in the Visual Studio exception helper dialog to "copy exception details to the clipboard".
If the exception is occurring in the constructor of Form1 , then you'll need to post the code for that as well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In addition to Richards comments about the Form1 constructor, you may want to look at any static fields you have declared, as they are likely to be initialized around then as well.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I retrive the row from database using sql dataadapter in datatable
it works well for sometime.But some times it throws no column found exception.
I dont know what excatly problem is their it sometimes work & sometime throw an exception for same data.
|
|
|
|
|
For the time it does not work, please post the relevant code and/or SQL to let us examine it...It will be also useful to let us know what column not found...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
string query = "SELECT A.emp_id, A.emp_first_name, A.emp_last_name, B.vehicle_no FROM (SELECT emp_id, emp_first_name, emp_last_name FROM emp_detail WHERE (emp_id = (SELECT emp_id FROM Tag_Assign WHERE(Tag_no =(select tag_no from tag_master where tag_id='" + textBox2.Text.Trim() + "'))))) AS A CROSS JOIN (SELECT emp_id, vehicle_no FROM Tag_Assign AS Tag_Assign_1 WHERE(Tag_no =(select tag_no from tag_master where tag_id='" + textBox2.Text.Trim() + "'))) AS B";
DataTable dt = con.datasource(query.Trim());
if (dt.Rows.Count > 0)
{
lblEmp_name.Text = dt.Rows[0][1].ToString() + " " + dt.Rows[0][2].ToString();
lblVehicle_no.Text = dt.Rows[0][3].ToString();
}
In above code it gives exception at dt.Rows[0][0].ToString();
|
|
|
|
|
Possibly dt.Rows[0][0] is null. Debug it!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
dt.Rows[0][0] contains employee id but as i metioned earlier it sometime throws exception
|
|
|
|
|
So get your feet wet! Catch the case when it throws exception and check if it is null!!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
It catches IndexOutOfRange Exception .Can not find column 1
|
|
|
|
|
It only contains something if something can be found.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Your code is susceptible to SQL Injection[^]. You should change it to use a parameterised query. How easy that is to do will depend on the implementation of your custom datasource method.
You can also simplify your query quite significantly:
SELECT
ED.emp_id,
ED.emp_first_name,
ED.emp_last_name,
TA.vehicle_no
FROM
emp_detail As ED
INNER JOIN Tag_Assign As TA
ON TA.emp_id = ED.emp_id
INNER JOIN tag_master As TM
ON TA.Tag_no = TM.tag_no
WHERE
TM.tag_id = @tag_id
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank u so much for helping me out now its working. Thanks again
|
|
|
|
|
Hello Guys,
Am developing an EXE for Coundowntimer functionality, I have used the below code for creating countdowntimer.
In Present Code: We need to give input for the "Time" and then start the timer in the output dialog
(Please refer the attached file)
Am planning to implement a app.config for Countdowntimer.exe, so that i can give my time directly in Countdowntimer.config and when i run my Countdowntimer.exe, the timer automatically will pick the time details given in Countdowntimer.config as input and start the timer.
my present code:
namespace countdownTimer
{
public partial class Form1 : Form
{
public int seconds; // Seconds.
public int minutes; // Minutes.
public int hours; // Hours.
public bool paused; // State of the timer [PAUSED/WORKING].
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
if (paused != true)
{
if ((textBox1.Text != "") && (textBox2.Text != "") && (textBox3.Text != ""))
{
timer1.Enabled = true;
button2.Enabled = false;
textBox1.Enabled = false;
textBox2.Enabled = false;
textBox3.Enabled = false;
try
{
minutes = System.Convert.ToInt32(textBox2.Text);
seconds = System.Convert.ToInt32(textBox3.Text);
hours = System.Convert.ToInt32(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
MessageBox.Show("Incomplete settings!");
}
}
else
{
timer1.Enabled = true;
paused = false;
button2.Enabled = false;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
// Verify if the time didn't pass.
if ((minutes == 0) && (hours == 0) && (seconds == 0))
{
// If the time is over, clear all settings and fields.
// Also, show the message, notifying that the time is over.
timer1.Enabled = false;
button2.Enabled = true;
textBox3.Clear();
textBox2.Clear();
textBox1.Enabled = true;
textBox3.Enabled = true;
textBox2.Enabled = true;
textBox1.Enabled = true;
lblHr.Text = "00";
lblMin.Text = "00";
lblSec.Text = "00";
}
else
{
// Else continue counting.
if (seconds < 1)
{
seconds = 59;
if (minutes == 0)
{
minutes = 59;
if (hours != 0)
hours -= 1;
}
else
{
minutes -= 1;
}
}
else
seconds -= 1;
// Display the current values of hours, minutes and seconds in
// the corresponding fields.
lblHr.Text = hours.ToString();
lblMin.Text = minutes.ToString();
lblSec.Text = seconds.ToString();
}
}
private void button3_Click(object sender, EventArgs e)
{
// Stop the timer.
paused = false;
timer1.Enabled = false;
button2.Enabled = true;
textBox3.Clear();
textBox2.Clear();
textBox1.Clear();
textBox1.Enabled = true;
textBox3.Enabled = true;
textBox2.Enabled = true;
textBox1.Enabled = true;
lblHr.Text = "00";
lblMin.Text = "00";
lblSec.Text = "00";
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Please suggest how do i provide a the input to the timer Hr: Min: Sec using app.config file.
-- modified 19-Jul-14 7:18am.
|
|
|
|
|
In your configuration file, you can add following section:
<appSettings>
<add key ="SomeKey" value="Somevalue"/>
</appSettings>
In code, you can access it using this line:
string valueFromConfig = ConfigurationManager.AppSettings["SomeKey"];
For more complex values in configuration, you can create your own configuration section and use that.
|
|
|
|
|
How to create Virtual Drive in c#?
|
|
|
|
|
|
Like this[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
How can I map a class to a table that has two primary keys, I have a table called Region that has two primary keys, RegionID and DistrictID, here is my code: can someone tell me what I am missing? Thanks
Class Region
{
[Key, Display(Name = "RegionID")]
public int RegionID {get;set;}
[Key, Display(Name = "DistrictID")}
public int DistrictID {get;set;}
.....
}
|
|
|
|
|
A table can't have two primary keys; do you mean that the key includes both columns?
And which framework/ORM are you using?
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Yes, it's a primary that has two columns, RegionID and DistrictID
|
|
|
|