|
|
Look into OAuth2
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
HI,,
IN A FORM USER INFORMATION AND PICTUREBOX....PICTURE TAKEN FROM CAMERA...AND IN PICTURE BOX DATE TIME AND OTHER TEXT IS ON PICTURE...
ON PRINTING I WANT DATE TIME AND OTHER TEXT ON PICTUREBOX IS TO BE PRINT....
BUT ON SAVING THE PICTURE ONLY PICTURE IS TO BE SAVED NOT DATE TIME AND TEXT IS TO BE DISPLAYED IN SAVED PICTURE.
|
|
|
|
|
You need to learn how to ask a question, see the sticky at the top of the list!
Don't shout (that is typing in all caps)
Don't post in multiple forums, select the most appropriate and post ONCE.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello all,
So I need your help to get a value from a string and put it on other field. I saw tons of exemples around, but I have several issues.
So I have a field named "Comments". I need to check if that field has some words on it. After find one of those words, I need to get the value after that word and pass it to another field named "Selo".
So far I have this code:
private string selos;
public string Selos
{
get { return selos; }
5. set
{
string[] stringToCheck = new string[] { "Selo:", "selo:", "Selos:", "selos:" };
string[] result;
if(string.IsNullOrEmpty(Comments) == true)
10. {
SetPropertyValue("Selos", ref selos, "None");
}
else
{
15. result = Comments.Split(stringToCheck, StringSplitOptions.RemoveEmptyEntries);
SetPropertyValue("Selos", ref selos, result[0]);
}
}
}
Issue 1: I filled the fields "Comments" but in VisualStudio - Watch, this field is allways null, so everything else is null. Issue 2: When I change the "Comments" data, the VS Watch recognizes changes and passes all the data in this field to the "Selos" field, which is not what I want. I just want data after stringToCheck...
Here's an exemple:
Comments: Everythings OK. Selo: Q457896; Q457897
Now, the code puts in "Selo" field: Everythings OK. Selo: Q457896; Q457897, however, it doesn't save this value in the database. What I really want is:
Field Selo - Q457896; Q457897
Please I need your help to get this working... What am I missing/doing wrong here?
Thanks
|
|
|
|
|
So if I get you correctly you want to update the property Selo if the comments property has the word "Selo" or some other pre-defined variable in it or add the first value from the comments once it has been broken up.
public class something
{
public string Comments {get; private set;}
public string Selos {get;set;}
public void SetComments(string comment)
{
string[] wordsToFind = new string[] {"Selo:", "selo:", "Selos:", "selos:"};
if(String.IsNullOrEmpty(comment) == true)
{
Selos = "None";
}
else
{
string[] result = comment.Split(wordsToFind, StringSplitOptions.RemoveEmptyEntries);
Selos = resuls[0];
}
}
}
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
So much wrong, where do I begin...
First, a caveat. There is not enough code he to get a complete picture of what you're doing and how you're using this code.
You're using a property incorrectly. You're using it as essentially a readonly property and a method to try and parse an input. I'd probably break this into a REAL readonly property with only a getter and then a method to parse the input and set the property backing field. You're not using the value supplied by the property settor.
The backing field I would probably rename to _selos to make sure its differentiated from all other mentions of it in the code.
The method to parse the input would probably be easier with a regular expression instead of using the "magic values" and very nainve method you're using. What if the comment contains "sEro:"? It's going to fail. Use a case-insensitive check instead.
Also, when you split the Comment string you're using the first element in the resulting string array, which is always going to be to first word in the Comment, in your example it's "Everything".
Free form user input is not the best idea. If you can avoid it, do so. If not, treat it like it's out to destroy the world. Don't trust it to contain anything usable at all and if it does, don't trust it to be in a format you can easily parse.
|
|
|
|
|
Hi, I'm trying to solve this error but without success. I have my interface:
public interface IAmInterface
{
string Method(string username, string password);
}
And a class which implements a Method:
public class Service : IAmInterface
{
public string Method(string username, string password)
{
return "Some string";
}
}
public class SomeClass
{
private readonly IAmInterface _name;
public SomeClass(IAmInterface userinterface)
{
_name = userinterface;
}
public void Method2
{
var name1=_name.Method("a","b");
}
}
I always get the same error when I try to call a method in Method2: object reference not set to an instance of an object.
What I'm doing wrong?
|
|
|
|
|
I don't see anywhere where you are instantiating Service. If it's null , you can't successfully call Method.
This space for rent
|
|
|
|
|
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.
Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which means that there is no instance of a class in the variable.
It's a bit like a pocket: you have a pocket in your shirt, which you use to hold a pen. If you reach into the pocket and find there isn't a pen there, you can't sign your name on a piece of paper - and you will get very funny looks if you try! The empty pocket is giving you a null value (no pen here!) so you can't do anything that you would normally do once you retrieved your pen. Why is it empty? That's the question - it may be that you forgot to pick up your pen when you left the house this morning, or possibly you left the pen in the pocket of yesterdays shirt when you took it off last night.
We can't tell, because we weren't there, and even more importantly, we can't even see your shirt, much less what is in the pocket!
Back to computers, and you have done the same thing, somehow - and we can't see all your code, much less run it and find out what contains null when it shouldn't.
But you can - and Visual Studio will help you here. Run your program in the debugger and when it fails, VS will show you the line it found the problem on. You can then start looking at the various parts of it to see what value is null and start looking back through your code to find out why. So put a breakpoint at the beginning of the method containing the error line, and run your program from the start again. This time, VS will stop before the error, and let you examine what is going on by stepping through the code looking at your values.
But we can't do that - we don't have your code, we don't know how to use it if we did have it, we don't have your data. So try it - and see how much information you can find out!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
No instance of _name created anywhere? You need to create an instance of Service first.
|
|
|
|
|
I'm creating a C# app with an SQL Server database.
In one module, the user has the option to filter the results by clicking on one of the two radio buttons (one is already selected by default), and I don't want to have to keep on re-accessing the database each time the user switches between the filters as it might consume time when the app has to load the data.
I'm using DataAdapter , DataTable , and DataGridView
Is there a way for me to somehow store the data from the database in a cache and then access them and show results that match the filter? How?
modified 29-Aug-16 12:10pm.
|
|
|
|
|
Download a dataset / datatable that can satisfy either filter; then filter THAT locally as required.
|
|
|
|
|
I will give this a try. Thank you
|
|
|
|
|
try
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("sami.goswami@gmail.com");
mail.To.Add(txtto.Text);
mail.Subject = txtsub.Text;
mail.Body = txtmsg.Text;
SmtpClient Smtpserver = new SmtpClient();
Smtpserver.Credentials = new NetworkCredential("sami.goswami@gmail.com", "password", "smtp.gmail.com");
Smtpserver.Host = "smtp.gmail.com";
Smtpserver.Port = 587;
Smtpserver.DeliveryMethod = SmtpDeliveryMethod.Network;
Smtpserver.EnableSsl = true;
Smtpserver.UseDefaultCredentials = false;
Smtpserver.Send(mail);
label1.Text = "Email successfully sent";
}
catch (Exception ex)
{
label1.Text = "Email failed" + ex.Message;
}
web.config
<pre lang="XML"><configuration>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="sami.goswami@gmail.com">
<network defaultCredentials="false" host="smtp.gmail.com" port="25" userName="sami.goswami@gmail.com" password="password"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
|
|
|
|
|
Don;t post this in multiple places: it duplicates work and annoys people.
You already have this posted in QA, leave it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi, i try to change the background color of RadGridView in background color property but it is not work!! please help me.
Note: I don't want change the background color of row or cell, i want change the background color of RadGridView white to other color? plese help me...
modified 29-Aug-16 13:31pm.
|
|
|
|
|
Why environment? MVC? WPF? Silverlight? WinForms?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
|
hi all,
i want to set custom paper size on printer.
i tried this.
<pre lang="c#">
PaperSize paperSize = new PaperSize("Custom", Current_Paper_Width, Current_Paper_Height);
paperSize.RawKind = (int)PaperKind.Custom;
Current_setting.PaperSize = paperSize;
printDocument1.DefaultPageSettings = Current_setting;
its change the size but the printable area not change.
please help me for this.
thanks.
|
|
|
|
|
You need to use the PageSettings[^] to change the printable area.
|
|
|
|
|
printable area parameter is use only to get value
how can i set
|
|
|
|
|
See the Remarks section on the link I gave you.
|
|
|
|
|
I have been looking for a way to detect when the a console application has ended. I want the ability to do some cleanup. Similar to Application.ApplicationExit in forms applications. I've scoured google, code project, msdn, etc. but no solid solution.
I thought about simply launching a cleanup thread at the start of the program and have it Join the main thread. Once that happens perform cleanup. I tried a test application (see code below):
static void Main(string[] args)
{
Thread cleanupThread = new Thread(cleanupThreadStart);
cleanupThread.Start(Thread.CurrentThread);
Thread.Sleep(5000);
Console.WriteLine("Main: Ended.");
}
private static void cleanupThreadStart(object state)
{
Thread mainThread = (Thread)state;
Console.WriteLine("cleanupThreadStart: Waiting for main thread to exit.");
mainThread.Join();
Console.WriteLine("cleanupThreadStart: Ended.");
}
Oddly, this solution works from within VS when I start with debugging (F5), meaning that the main thread will end and the cleanup thread will complete the join and I'll see the console printout. However if I start without debugging (ctrl+F5 or simply run the executable directly) the program hangs because the main thread ends but the cleanup thread never completes the Join. I've tried attaching to the process from within VS during the hang and I can see that the main thread is no longer present but the cleanup thread is still waiting for the Join to complete.
Does anybody know why this works with debugging active but not without it? Does anybody have any other clever way of detecting that the application is about to end (similar to Application.ApplicationExit)?
For now I've got a workaround to just create my own "main" thread which executes the normal application code. Then my cleanup thread joins with this thread before cleanup. This seems to work fine.
|
|
|
|
|
I'm interested in this sort of thing myself - one of the things I found was
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
<pre>
}
static void CurrentDomain_ProcessExit(object sender, EventArgs e)
{
Console.WriteLine("exit");
}
}</pre>
Im also working on handling the Ctrl/C, Ctrl/Break, 'X' to detect app shutdown as well
|
|
|
|