|
Thanks John. I tried that earlier and I think I got the cast wrong. I put the ')' after the ToString() instead of after the Column name.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
I don't know your code but ...
DataRows contain type information and the value from the collection in the row object is castable to it's underlying type. Basically, (string)dr["someValue"], or more importantly (DateTime)dr["someDate"].
While the code works, it masks what is being performed by performing a completely different operation.
BTW, the db date format is usually saved as a global DB setting that can be changed.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Hi
I'm a newbie c# programmer and have written a custom validator to validate 2 controls on a web form. I have other controls too on the same form which use the standard ASP.Net validation controls and they work perfectly however, although my custom validator works and writes the error messages to the web form, it also wants to fire off the addVehicleToDB method which is called by clicking the Submit button. This is ok of course if data entry is correct but it happens even when e.IsValid = false;! Obviously I am not fully understanding the order in which events happen so if someone could point me in the right direction that would be great.
Here is my custom validator function which is linked to a text box:
public void ValidateModelType(Object s, ServerValidateEventArgs e)
{
lblNoType.Text = "got here";
//if the text box is null
if (e.Value == "")
{
//check that model type has been selected from drop-down list
if (ddlModelTypes.SelectedItem == null)
{
lblNoType.Text = "not valid!";
e.IsValid = false;
}
else
{
lblNoType.Text = "all ok";
e.IsValid = true;
}
}
}
Thanks
Lorna
|
|
|
|
|
InvalidForumException was thrown by your question. Please make sure you post your question in correct forum. Your post has been terminated.
|
|
|
|
|
Hi Everyone,
I ve my c# application,
in that i want to set some settings in Registry.
To authenticate the user i want the user to enter
local system's current username and password.
How can i verify the entered username and password?
Any solution...?
Regards,
-SIFAR.
|
|
|
|
|
Avoid using the registry. Use the built-in user settings instead. As for the login stuff, I'm sure you'll find an answer if you google it.
[EDIT] What you could do is use Windows authentication, and verify that the currently logged in user is within a certain group. The following criteria should probably be used to verify the user:
0) The required group must be defined on the box.
1) The currently logged-in user must be in the specified group.
2) (Optionally) The user must not be in the administrator group.
If you don't want to use Windows Authentication, you could set up your own and use an XML file to hold user ID's and passwords (encrypted or hashed of course).
[EDIT] This question inspired me to look into windows form login functionality, and I'm writing an article about it. If you can wait a few days, I'll post a reasonably complete solution (if I don't get bored with the whole thing in the process). The sample application is what will require the most time.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Thursday, October 2, 2008 10:28 AM
|
|
|
|
|
Thanx John,
Looking forward for your further post.
Regards,
-SIFAR.
|
|
|
|
|
Here's an article I wrote today about login. See if that's what you want.
http://www.codeproject.com/KB/miscctrl/Application_Login.aspx[^]
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'm trying to get an exe file running on the PC that can be called from any of several of our applications that are installed on a user's PC. If the exe is already running, i'm using Remoting and the IPC channel and this seems to work fine.
I'm now trying to find a way of calling into the exe if it's not running. Is it possible to make my method static and for the application to launch itself if there is not an instance of itself running already?
Cheers,
Russell
|
|
|
|
|
The easier way to do this would be to modify the executable so that only 1 instance of it could run at any time. (Google for articles on this there are loads)
Then always have you apps run the exe first, which will start it up if it is not already running. if it is already running, the single instance only code will kick in, and prevent it from running a second time.
Simon
|
|
|
|
|
I thought of doing that but then couldn't work out what to do with the calling parameters as the soon to be dead exe will be in a different process to the already running one. I guess though that if i create the IPC channel after the check then the exe that's about to quit can pass its parameters to the one that's already running before it exits.
Thanks for the response
Russell
|
|
|
|
|
In the constructor of the Main class put some code that checks the list of processes that are running at that time. If you find you're exe there, just close the current one.
|
|
|
|
|
Hi to all,
I made a WebService with visual studio 2008 (c#). I need to deploy it on IIS7 (windows server 2008).
I made a web setup project deployement but when i tried to run the msi file on the server it gaves me this message : "The installer was interrupted before WebServiceXXX could be installed. You need to restart the installer and try again."
does anyone knows why ? how can i do to install my web service on IIS7 (windows server 2008) ?
thanks for any ideas.
best regards and thanks in advance
Fady Sayegh
|
|
|
|
|
Dear all,
is is possible to call a static method from a non-static method and the other way around eg.:
private void Test1()
{
Test2();
}
private static void Test2()
{
}
The example above will generate an error, but I would like to know if , and how it can be done.
Thank you for any assistance.
Kind regards,
|
|
|
|
|
Do you know how to call static methods from outside the class where it is defined? You can call it in the same way. If not then it means that you are not familiar with static methods so why do you use it? As for second question you will need an instance of a class that defines nonstatic method.
|
|
|
|
|
Within the same class, an instance method can call a static, but a static cannot call an instance.
|
|
|
|
|
unless you pass an instance reference to it...
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
The only way to do this is to have your Test2 method have an instance of the class as a parameter or make one available to it in some other way.
|
|
|
|
|
I have an application with a form containing 2 textboxes and an animated GIF, this form works fine in all version of Windows that I have tried it on except Vista, for some reason the textboxes show the desktop through them and the GIF does not move. This is designed in VS 2003 using C# .NET 1.1.
Has anyone seen this behaviour before or have an idea what might cause it?
|
|
|
|
|
PRNADMINLib.PrinterCollection prnColl =
(PRNADMINLib.PrinterCollection)oMaster.get_Printers(ref oServerName);
I have the name of the server as a string which I believe needs to go into get_printers parameter but this parameter is expecting an object i.e. ref oServerName.
How can I pass my server string name to this object parameter?
Thanks
|
|
|
|
|
|
This isi what I am using withthe same issue.
Not sure how to pass the servername.
Thanks
PRNADMINLib.PrintMaster oMaster = new PRNADMINLib.PrintMasterClass();
PRNADMINLib.Printer pPrinter = null;
PRNADMINLib.PrinterCollection prnColl =
(PRNADMINLib.PrinterCollection)oMaster.get_Printers(ref oServerName);
IEnumerator prnEnumerator = prnColl.GetEnumerator();
prnEnumerator.Reset();
while (prnEnumerator.MoveNext())
{
PRNADMINLib.Printer prnCurrent = prnEnumerator.Current as PRNADMINLib.Printer;
if (prnCurrent.PrinterName == strPrinter)
{
pPrinter = prnCurrent;
break;
}
}
|
|
|
|
|
Hello DaveyM69
I am using the code in that article but the issue is where to get the oServerName as object?
I even tried the following code with slight changes to my previous code.
This is what I have now and error is FileNotFoundException on line:
PRNADMINLib.PrinterCollection prnColl =
(PRNADMINLib.PrinterCollection)oMaster.get_Printers(ref obj);
The actual error is:
The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)
PRNADMINLib.PrintMaster oMaster = new PRNADMINLib.PrintMasterClass();
PRNADMINLib.Printer pPrinter = null;
object obj = txtServerName.Text.Trim();
PRNADMINLib.PrinterCollection prnColl =
(PRNADMINLib.PrinterCollection)oMaster.get_Printers(ref obj);
IEnumerator prnEnumerator = prnColl.GetEnumerator();
prnEnumerator.Reset();
while (prnEnumerator.MoveNext())
{
PRNADMINLib.Printer prnCurrent = prnEnumerator.Current as PRNADMINLib.Printer;
if (prnCurrent.PrinterName == strPrinter)
{
pPrinter = prnCurrent;
break;
}
}
|
|
|
|
|
I have corrected the code as follows but it seems the data is retrieved from the local machine as opposed to the ServerName.
Any suggestions?
PRNADMINLib.PrintMaster oMaster = new PRNADMINLib.PrintMasterClass();
PRNADMINLib.Printer pPrinter = null;
clsServer oServerName = new clsServer();
object obj = oServerName;
PRNADMINLib.PrinterCollection prnColl =
(PRNADMINLib.PrinterCollection)oMaster.get_Printers(ref obj);
IEnumerator prnEnumerator = prnColl.GetEnumerator();
prnEnumerator.Reset();
while (prnEnumerator.MoveNext())
{
PRNADMINLib.Printer prnCurrent = prnEnumerator.Current as PRNADMINLib.Printer;
if (prnCurrent.PrinterName == strPrinter)
{
pPrinter = prnCurrent;
break;
}
}
|
|
|
|
|
I really haven't got a clue - I just found some online resources that I thought might help you.
This page[^] has loads of info on printing of all kinds including (about halfway down) prnadmin.dll. It has a section on Enumerating Printers - but you should probably read and understand all of it before jumping to that section. It's in VB - (maybe VBS? I didn't check) but it should get you started - maybe try it at get it working in that language before translating so you'll know wheter it's a network/permission problem or just your code if it doesn't function.
I can't help you anymore than this. I have no experience of your particular problem and it seems noone else here has either as you've been asking for a long time and not got a solution, so if this doesn't help, you may be on your own. Good luck!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|