|
Should be:
if (string.IsNullOrEmpty(txtUser.Text) || string.IsNullOrEmpty(txtPassword.Text))
Use the IDE to check where your matching parentheses are, or should be.
|
|
|
|
|
if (string.IsNullOrEmpty(txtPassword.Text) || (string.IsNullOrEmpty(txtUser.Text)))
MessageBox.Show("field empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Files mf = new Files();
Hide();
mf.ShowDialog();
Close();
}
*theres my code ,its practicly a button that opens another form,and if the fields are empty popup error but when i click ok , the other form still opens, whats the addon code, (== DialogResult.Ok)??
|
|
|
|
|
Yes, you should check the result of the MessageBox.Show message, and perhaps put a better message, and extra button, so the user can continue or cancel. Alternatively, if this error is unrecoverable, you should just exit aftger the message is dismissed by the user.
|
|
|
|
|
i fixed it my fault was i put the ) in but shudve put it iin the end, how do i close it im new here
|
|
|
|
|
jamesmc1535 wrote: how do i close it Close what?
|
|
|
|
|
well not close , u said if its marked as dismissed or something like that i should exit did you mean the program
|
|
|
|
|
I don't know, it all depends on what the application is doing at the time, and what it is supposed to do in these circumstances. You may want to close the main form and then open some other form for further work, or you may just want to close the program.
|
|
|
|
|
okay so this is my problem , i have a button on a form and 2 textboxes,and what i want to do is "create a admin account" where i type into the text boxes "example" username :admin password :admin " and then have it moved on to the next form and if the password/username is incorrect have a message popping up. the messagebox isnt a problem, i just dont know about the username,and will i be able to do it without sql (temporary)?
|
|
|
|
|
You can store the username in your application properties as a temporary measure.
|
|
|
|
|
Hello. I know there is a way to enable and disable speech recognition because you can do pretty much anything in c#. I am stuck on how to enable and disable speech recognition by using my voice. This is the scenario that I want to achieve.
When I say start listening I want my program to accept voice commands. When I say stop listening I want my program to reject all voice commands, apart from "start listening", however only listen out for the command "start listening" to enable full voice command control again.
Does anyone have any ideas on how I can go about doing this?
|
|
|
|
|
Member 11839664 wrote: Does anyone have any ideas on how I can go about doing this? You probably need to start by creating a program that uses the Speech API and recognises those two phrases. Once you have that working you can move on to the more advanced aspects.
|
|
|
|
|
I've used SAPI to do that. Now what do i do
|
|
|
|
|
What code do you currently have?
|
|
|
|
|
No idea. This is your application so only you know what it is supposed to do.
|
|
|
|
|
Set a flag in your application that denotes it's not supposed to process certain commands? Seems kind of obvious to me.
|
|
|
|
|
Hi,
I receive a string from an API like this example:
{"id":"30535","email":"myemail@yahoo.com","first_name":"John","last_name":"Smith","gender":"male","friends":{"data":[{"name":"Helen Ford","id":"68304"},{"name":"Leo Pitt","id":"4732"}]
I'd like to split and save the values into these
string personId
string email
string firstName
string lastName
string gender
and for friends values into an array that contains these values "personId" and "name" (for each set of records)
I'd really appreciate it if someone could help me.
|
|
|
|
|
|
|
hi
i have this query in access that run's excellent ! ,I called her MyQUERY
SELECT BK_LEVEL9.Aitur AS Aitur, Sum(BK_LEVEL9.M_NewQty) AS M_NewQty, Sum(BK_LEVEL9.ErrorCount) AS ErrorCount, (IIf([M_NewQty]<>0,Round(([ErrorCount]*100)/[M_NewQty],2),0)) AS ErrorProcc
FROM BK_LEVEL9
GROUP BY BK_LEVEL9.Aitur;
in my C# program i try to run her like this:
SQL = "SELECT Aitur,M_NewQty,ErrorCount,ErrorProcc from MyQUERY";
dsWorkKabat = new DataSet();
adp = new OleDbDataAdapter(SQL, Conn);
adp.Fill(dsWorkKabat, "MyQUERY");
adp.Dispose();
and i got this error:
You tried to execute a query that does not include the specified expression 'IIf(Not [M_NewQty]=0,Round([ErrorCount]*100/[M_NewQty],2),0)' as part of an aggregate function.
What could be the problem ?
thanks
|
|
|
|
|
You seem to be missing the formula from your GROUP BY clause. So try something like:
SELECT BK_LEVEL9.Aitur AS Aitur,
Sum(BK_LEVEL9.M_NewQty) AS M_NewQty,
Sum(BK_LEVEL9.ErrorCount) AS ErrorCount,
(IIf([M_NewQty]<>0,Round(([ErrorCount]*100)/[M_NewQty],2),0)) AS ErrorProcc
FROM BK_LEVEL9
GROUP BY BK_LEVEL9.Aitur,
(IIf([M_NewQty]<>0,Round(([ErrorCount]*100)/[M_NewQty],2),0));
|
|
|
|
|
GrabMemberAndProductInformation - This method is adatabase call and returns a DataTable.
SetupAccountListForMember - This method takes in a dataTable, does some calculation on each record and then adds the record to a listbox.
try
{
Task fetchMemberAccounts = Task.Factory.StartNew<DataTable>(GrabMemberAndProductInformation)
.ContinueWith(antecedent => SetupAccountListForMember(antecedent.Result),
TaskScheduler.FromCurrentSynchronizationContext());
catch (AggregateException err)
{
...log error
}
Now when an exception is thrown the exception seems to be swallowed by the CLR and does not trigger the exception handling I have in place. Can someone explain to me why the catch block is not being triggered? Any help is appreciated.
Thanks
Matt
|
|
|
|
|
You are creating a new thread. Exceptions occuring on the thread will not propagate to your catch-clause. The code on the thread ("task") needs its own exception handling.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Matt - in order to work out what errors are being thrown, you need to add an exception continuation to your task, so you would end up with the following:
Task errorTask = fetchMemberAccounts.ContinueWith(ex => { }, TaskContinuationOptions.OnlyOnFaulted);
|
|
|
|
|
If you can upgrade to .NET 4.5, async / await makes this type of code much easier to write.
try
{
DataTable data = await Task.Run(GrabMemberAndProductInformation);
SetupAccountListForMember(data);
}
catch (DbException err)
{
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This worked nicely. Thanks for your help.
Matt
|
|
|
|