|
I haven't written an article on Selenium so your message obviously isn't directed at me. I'm pretty sure none of the regulars here have either.
When you have a question about an article, the correct place to ask your question is on the forum at the end of the article. Don't post in a random place hoping that the author will stumble across it.
|
|
|
|
|
Hello,
Apologies for what surely is a very basic question. I'm new to C# and need to write some easy functions for an application we use at work. This application uses a special DateTime as it needs to accommodate unknown date parts, e.g. UNK/May/2015. Ideally I would like to know the difference in months between two dates, but for a start I'm happy with just the year difference (the year will always be known). I've written the following function which throws no errors but it always returns 0. I can see while debugging that StDt.Year and EnSt.Year are integers with the correct year, but it doesn't seem to calculate the PackYears. Any help is greatly appreciated!
[DesignerFunction("Calculates the pack years")]
public static int fnCalculatePackYears(
[DesignerParameter("Start Date (date)")] PFDateTime StDt,
[DesignerParameter("End Date (date)")] PFDateTime EnDt)
{
int PackYears = 0;
int StDtYr = StDt.Year;
int EnDtYr = EnDt.Year;
PackYears = (EnDt.Year - StDt.Year);
return PackYears;
}
Thanks in advance!
Nicole
|
|
|
|
|
Without knowing more about your PFDateTime class, we can't really help you. Except to say why are you reading the year values into variables, and then ignoring them?
So start with the debugger.
Put a breakpoint on your return statement, and run your app in the debugger. When it hits the breakpoint, it will stop. Look at the values of PackYears (it'll be zero if you are right), at StDtYr and EnDtYr I'm just guessing that they are the same value...and probably zero.
So look at the inputs, and see what they contain.
We can't do any of that for you - we can't run your code!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Member 12008340 wrote: I can see while debugging that StDt.Year and EnSt.Year are integers with the correct year Then you should also be able to see the result of the calculation (what are the two years' values?). Are you sure this is the exact code you are debugging?
|
|
|
|
|
Good afternon
I am saepul from indonesia
i have question
where my question is
how sintax make automatic number where that automatic number
include year moth day and counter number
thanks very much
bestregard
saepul
|
|
|
|
|
Where are you getting your counter number from? The reason I ask this is because if you rely on a program to maintain a running total then you are probably going to have problems if the application crashes and restarts - you'll get duplicated numbers and it seems likely that this isn't what you want. Is the number meant to be an identity field in a database?
|
|
|
|
|
STOP SHOUTING.
Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Good Afternonn,
I am saepul from INDONESIA
I have question about view data from database,
where my question is
how sintax to call data from database to datagridview
where that sintax in class and that sintax i call on the form
thanks
bestregards
saepul
|
|
|
|
|
|
Hello,
I want to return a string color based on these 4 calculations.
X = 25%
5.0% >= X >= -5.0% blue
+15.0% >= X > +5.0% and -5.0% > X >= -15.0% yellow
+25.0% >= X > +15.0% and -15.0% > X >= -25% green
X > +25.0% and X < -25.0% red
I am having trouble forming the logic. Thank you for the help.
|
|
|
|
|
Off the top of my head - untested!
int x = 25;
Color c = GetColor (x);
public Color GetColor
(int x)
{
if ((x <= 5) && (x >= -5))
return Color.Blue;
if ((x <= 15) && (x >= -15))
return Color.Yellow;
if ((x <= 25) && (x >= -25))
return Color.Green;
return Color.Red;
}
/ravi
|
|
|
|
|
I want a indian language converter in c#
Means Type in English in one text box and convert it in another textbox in Gujarati, Hindi, etc
Pls help me on this
Thank you
V.A.Jani
|
|
|
|
|
|
Thank you sir for reply,
But I want the solution for offline, for windows application
Vishal Jani
|
|
|
|
|
Are you planning on writing one, or looking for someone to do so?
If the first, then you should investigate how to keep a list in a database, and how to fetch an item from it. If the second, then you are on the wrong site.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
It's an API. As long as there's an internet connection, you can call the API. You do realise we aren't going to pre-roll the code for you don't you?
|
|
|
|
|
Pete O'Hanlon wrote: You do realise we aren't going to pre-roll the code for you don't you? You mean like this[^]?
/ravi
|
|
|
|
|
Google for (any) C# tutorial.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
hi I'm try to using this Par of code Download From CODE PROJECT
and It's gave an error .
" unsupported key version" is any one can tell me how to handle it
private void btnGenerateLicenseKey_Click(object sender, EventArgs e)
{
LicenseTemplate tmpl = new LicenseTemplate(4,4,"test","test",109,16,"Prod_Id");
//LicenseTemplate tmpl = new LicenseTemplate(5,// number of groups of characters in the license key
// 5, // number of character in each group
// // the public/private key pair below was generated with a call to KeyGemplate.GenerateSigningKeyPair()
// "test", // the public key used to verify the license key signature
// "test", // private key used to digitally sign the license key
// 109,// signature size of the license key is 109 bits
// 16,// data size embedded in the license key is 16 bits
// "ProductId" // this is the name of the data field embedded in the license key
// );
KeyGenerator keyGen = new KeyGenerator(tmpl);
KeyValidator keyval = new KeyValidator(tmpl);
keyGen.SetKeyData("Prod_Id", 12345); // embed our product id into the license key
txtLicenseKey.Text = keyGen.GenerateKey();
}
modified 23-Sep-15 2:19am.
|
|
|
|
|
Don't post this here - if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I am making a small project to build my skills, and what I am trying to do is query a DataSet which is filled from a SQL database using a SELECT query.
However, I cannot manage to query the dataset further, I would like to be able to search the dataset and it will pull up results, this is what I have so far, though I get this error - An unhandled exception of type 'System.NullReferenceException' occurred
My table is called Animals, and I am searching in the parlour_number column.
I have searched, but I don't understand most of what I have looked at, I have a very basic understanding still.
DataSet ds;
DataRow dRow;
private void searchBtn_Click(object sender, EventArgs e)
{
string searchFor = tbSearch.Text;
int results = 0;
DataRow[] returnedRows;
returnedRows = ds.Tables["Animals"].Select("parlour_number='" + searchFor + "'");
results = returnedRows.Length;
if(results > 0)
{
dRow = returnedRows[0];
MessageBox.Show(dRow[1].ToString() + " " + dRow[2].ToString());
}
else
{
MessageBox.Show("No records found");
}
}
It breaks at the
returnedRows = ds.Tables["Animals"].Select("gender='" + searchFor + "'");
and tells me that there is a Null value.
returnedRows is null, but should my query not populate it?
Thanks.
|
|
|
|
|
you don't show (us) some of the more important/pertinent information we would need to be able to help you - for example :-
Member 11956589 wrote: which is filled from a SQL database using a SELECT query - seeing how you do this might help
You don't say / indicate (unless Im going blind in my dotage) WHERE your exception occurs
Finally - you're starting with a query - why don't you run a loop over the rows in ds.Tables["Animals"] and/or do some other diagnostics first, to see/prove it is being populated correctly - else your query will be worthless if you're not getting that far
[edit]
Think about something like this - before you attempt your query, to see if the data[set|table] is being populated correctly
foreach (DataRow animalsDataRow in ds.Tables["Animals"].Rows)
{
}
[/edit]
modified 22-Sep-15 20:51pm.
|
|
|
|
|
Member 11956589 wrote: and tells me that there is a Null value. Yes. Either the dataset ds is null or there's no such table as "Animals" in it.
You can use Quick Watch under Visual Studio to find out which one it is. Add a debug point and hover (move your mouse pointer) over ds and see if it's null. If it's not, then see if it has the "Animals" table using Quick Watch or the Immediate Window.
You have just been Sharapova'd.
|
|
|
|
|
It is correct because you do not initialize your Dataset
DataSet ds = new Dataset();
You did not say any word how did you filled your dataset.
You can fill it with your search results like this:
private void searchBtn_Click(object sender, EventArgs e)
{
string connectionString = "Data Source= ... your connection string";
SqlDataAdapter da = new SqlDataAdapter(
"SELECT your fields " +
"FROM Animals" +
"WHERE gender = @searchFor",
connectionString);
da.SelectCommand.Parameters.AddWithValue("@searchFor", tbSearch.Text);
da.Fill(ds);
DataTable animals = ds.Tables["Animals"];
foreach (DataRow row in animals.Rows)
{
}
}
P.S: It is a bad practice to proceed SQL-query as string by adding values with "+". Please look for "sql injections".
It would be better to use Parameters.AddWithValue() method.
|
|
|
|