|
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
|
|
|
|
|
That's a compound primary key; RegionID and DistrictID aren't primary keys, they are foreign keys - if the combination uniquely identifies a record, then the combination of both fields is the primary key.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What? That can't be. A table has only one primary key.
Don't mind those people who say you're not HOT. At least you know you're COOL.
I'm not afraid of falling, I'm afraid of the sudden stop at the end of the fall! - Richard Andrew x64
|
|
|
|
|
First we need to clarify what you mean with "two primary keys". Is it a rpimary key which consists of both "RegionID" and "DistrictID"? Or did you calculate an extra value from those data and make that your primary key?
Or is it actually one foreign key and one primary key?
Or something else?
|
|
|
|
|
Thanks for your reply, yes, it's a primary key which consitsts of both RegionID and DistrictID.
|
|
|
|
|
a 'compound' primary key.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks, can you provide a simple code? Thanks
public class Region
{
// what I should define here
public int RegionID {get;set;}
// then what I should define here
public int DistrictID {get;set;}
}
|
|
|
|
|
You haven't stated what database you're using or whether you are using an ORM (which it looks like you are), and if so which one.
Personally I never use ORMs, so I can't advise I'm afraid.
Regards,
Rob Philpott.
|
|
|
|
|
public class Region
{
[Key, Column(Order = 0)]
public int RegionId { get; set; }
[Key, Column(Order = 1)]
public int DistrictId { get; set; }
} That is, assuming you're using EF; you still did not specify which mapper you are using. I'd also like to recommend an artificial key, and to decorate your compound key with a unique-constraint. Having a single attribute to identify a record makes life a bit easier when having to reference a specific record.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you very much, I am runnig into an error when using Order, I have the using System.ComponentModel.DataAnnotations.Schema and System.ComponentModel.DataAnnotations, I am using VS12, can you tell me what I am missing? Thanks again.
|
|
|
|