|
I've got a form that is using an old COM object (AxSHDocVw.AxWebBrowser). Does anyone know how once I navigate to a screen I can automate logins using this control?
|
|
|
|
|
i write this cide to get data from data set but there is an error in line 10 and 11
why
if u plze help me and tell me how can i get all the data from data lis using for loop.
thanks in advance
1.OleDbConnection myConnection=new OleDbConnection("provider=microsoft.jet.oledb.4.0;datasource=alabrags.md");
2. DataSet ds1 =new DataSet();
3. OleDbCommand cmdsel1;
4. String sql1="select * from customers";
5. mdsel1=new OleDbCommand(sql1,myConnection);
6. OleDbDataAdapter myCommand1 ;
7. myCommand1=new OleDbDataAdapter();
8. myCommand1.SelectCommand=cmdsel1;
9. int total ;
10. total=ds1.Tables["customers"].Rows[0][1];
11. t1.Text=ds1.Tables["customers"].Rows[0[1].ToString();
MffM
maayah2000@yahoo.com
|
|
|
|
|
No place are you actually filling the dataset with data from your command. You are also setting up the select command, but are never executing it. There is a Fill command on the OleDbDataAdapter class that will fill in your DataSet. Call that between 8 and 9 and you should be good to go.
Steve Maier, MCSD MCAD
|
|
|
|
|
I have no previous programming knowledge and I have been learning C# for only 3 days, so bare with me if it is an extremely easy question.
As the title states,
age = (byte)(generator.NextDouble() * 100 - 20);
sometimes gives extremely high values, close to 255. I think its because when the program substracs 20 from the value it goes beyond 0 and starts discounting from 255.
Is there any way to stop it at 0 besides using an int?
I solved it by adding 25 if age is over 200, but there must be a better way to do it.
Here is the code, if you need it.
private static void doPersonnel()<br />
{<br />
Random generator = new Random();<br />
StreamWriter sw;<br />
int number = 0;<br />
byte dex, sma, wor, age, potAbility, ability;<br />
String line;<br />
while (number < 10000)<br />
{<br />
dex = (byte)(generator.NextDouble() * 255);<br />
sma = (byte)(generator.NextDouble() * 255);<br />
wor = (byte)(generator.NextDouble() * 255);<br />
age = (byte)(generator.NextDouble() * 100 - 20);<br />
if (age < 10 || age > 200)<br />
{<br />
age += 25;<br />
}<br />
do<br />
{<br />
potAbility = (byte)(generator.NextDouble() * 200);<br />
} while (potAbility < 1);<br />
do<br />
{<br />
ability = (byte)(generator.NextDouble() * 200);<br />
} while (ability > potAbility);<br />
line = Convert.ToString(dex + "," + sma + "," + wor + "," + age + "," + ability + "," + potAbility);<br />
sw = File.AppendText("D:\\Test.txt");<br />
sw.WriteLine("{0}", line);<br />
sw.Close();<br />
number++;<br />
}<br />
}
If I made any abvious mistakes tell me too please, its my first program after all
|
|
|
|
|
Yes, your thought is correct. You are picking a random number between -20 and 79, when you cast that to a byte, the values -20 to -1 becomes 236 to 255.
Why are you picking a number between -20 and 79 anyway? That seems like strange values for something called "age"... Are you attempting to pick a number between 20 and 99?
Anyhow, take a look at the Next() method of the Random class. It returns an integer value that is greater or equal to 0 and less than the specified maximum. This code gives the same result as your code, and creates a value between 0 and 254:
dex = generator.Next(255);
If you want a random number where the lower range is other than zero, you can get a random number where the lower range is zero, and just add a constant value. This creates a value between 20 and 99:
age = generator.Next(80) + 20;
But then again, there already exists a method for this:
age = generator.Next(20, 100);
---
I see that you are declaring byte variables. Unless you have some special plan that requires byte size variables, stick to the int data type. The processor internally only uses two data types; int and double. If you use these, your code will be faster.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks, the book Im reading only tells about the NextDouble method.
And thanks for the additional input, as I said Its only my third day.
I wanted to get ages between 5 and 80 BTW
|
|
|
|
|
It is hard to tell what you are trying to accomplish. I will take a guess - you are trying to create a random positive integer.
Take a look at the Random.Next(int maxValue) method.
For a human age you might use code like:
int age = generator.Next(100) + 1;
This would give you an age between 1 and 100. Casting the result of a double to a byte may not give you the randomness you desire.
|
|
|
|
|
You can also use this.
int age = generator.Next(5,80);
And it will generate one between 5 and 80 with one simple step.
Steve Maier, MCSD MCAD
|
|
|
|
|
hi
i have program on c# with ms sql.when i start the program on my comp is work excelent but when i install it on some other i get this message(install=copy program and paste it on other computer)how to deside the problem??
"APPLICATION HAS GENERETE AN EXCEPTION THAT CLOUD NOT BE HADNLED PROCES ID=0X75(1884),THREAD ID=0X6F8(1784)
Thank you
|
|
|
|
|
papa1980 wrote: "APPLICATION HAS GENERETE AN EXCEPTION THAT CLOUD NOT BE HADNLED PROCES ID=0X75(1884),THREAD ID=0X6F8(1784)
As your error says, an exception was generated, and probably you do not have a try/catch block in witch to handle it. Your exception may have occured because you rely on something that is on your computer and on others may not be...
Put a try/catch block in your main procedure and display the exception's message to find out why your application crashes on other sistems.
protected internal static readonly ... and I wish the list could continue ...
-- modified at 15:11 Monday 28th November, 2005
|
|
|
|
|
I have it
static void Main()
{
try
{
Application.Run(new MainForm());
}
catch(Exception exp)
{
MessageBox.Show(exp.ToString());
}
}
this problem is occure not when i compilate the program on my computer is ocrure when i copy the program on other computer and try to use it????
|
|
|
|
|
|
ok i have it.My program is work one time correct and one not ???? when is on other computer why ????
|
|
|
|
|
|
I have one single thing to say : LoL
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Hello:
i want to write a interrupt in c# but i don't now how can i get address of my function that i want to use it for ISR.
how can i do it?
|
|
|
|
|
In order to achive such things you must juggle with reflection, unmanaged code, marshaling and others ... not a very easy thing in c#
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
C# is most definitely NOT suitable for this. C# doesn't have direct access to the hardware because of Windows Hardware Abstraction Layer. Your best bet for this sort of thing is C++ and the Windows Device Driver Development Kit. You have to write a Ring 0 .DLL that runs behind the HAL and exposes an interface for your C# app to use.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
I'm working with vs.net 2003 in C#. I don't know how to create an empty report in cristal reports and then bind a DataSet. My goal is to change a sql statement in runtime. I think the easiest way to do this is by binding the dataset.
I came accross to some tutorials but the code like this does not want to work:
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
Empty_cr report = new Empty_cr();
report.SetDataSource( ds);
crDataViewer.ReportSource = report;
Why? What is the reason?
Maybe someone knows a really good tutorial?
Could anyone help me? Please!! This is very important for me and can simplify some things.
Regards:
Olg
|
|
|
|
|
I've created a windows service to ensure another service is running. First of
all, I look for the process relative to the service I'm monitoring. The code
is:
Process[] processes = Process.GetProcesses();
foreach(Process process in processes)
if(!process.HasExited &&
process.Id > 0 &&
process.ProcessName.ToLower() != "system" &&
process.MainModule.FileName.ToLower() == serviceDetail.ExecutablePath.ToLower())
...
The problem is with the MainModule property, called at the end of the if
statement. Internally, the MainModule property gets all modules for the
process and looks for the main one. So, if the process has exited, the search
for the process modules fails and we get an exception.
In order to solve this issue, I test the HasExited property at first place.
However, I still get an exception: "Cannot process request because the
process (3248) has exited." Why this exception occurs if I have tested the
HasExited property? Am I doing somethig wrong or missing something?
Another exception is thrown too. Sometimes I get an "Access is denied"
exception from this code piece.
Does anyone have any idea that could help me?
Thanks in advance.
Ricardo
|
|
|
|
|
Ricardo Mendes wrote: "Cannot process request because the
process (3248) has exited." Why this exception occurs if I have tested the
HasExited property? Am I doing somethig wrong or missing something?
A process is independent from your code. If a process is now running, in a couple of clock cicles can enter in an different state, in the same time that you do an other operation (let's say adding two numbers). I think you should try to lock your code when you execute it.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Hi,
From my normal application running in my computer i need to connect to PDA and send some data or activate a method.
An PDA application (.net based) is already running in the PDA.
what is the best way to do it? will really appreciate
regards,
rnv
|
|
|
|
|
Hi All,
I want to have a nested class which is generally accessible, but can only be instantiated by it's containing class. ie:-
public class Parent
{
public class Child
{
<ParentOnly> Child();
}
public Child GetANewChildObject()
{
return new Child();
}
}
C# doesn't seem to directly support this - the closest you can get is with the internal access modified, which is sub-optimal.
The only real solution i've found is to implement the child class in 2 classes- an abstract Child, and a private Child2 : Child . But that seems a bit clumsy. Is there a better way?
Thanks
Jon
using System.Beer;
|
|
|
|
|
I think the 2nd way you suggested is the most limiting while still being usefull. The internal approuch doesnt really 'block' it. Another option to limit it even more is to make the abstract class protected, or the inheriting class protected for less limitation. You can get quite funky with nested layouts.
xacc.ide-0.1 released! Download and screenshots
|
|
|
|
|
Hi,
I have a Widow service. I am installing the service and related applications using install shield. i have written a service installer class. This works fine when i am installing or Modifying the application using setup file.
It gives problem when i repair the application, since the service is already exist. I have tried to stop installing the service if it exists in the system but still it gives me error "Unsave state...". In service installer class i have override install and uninstall method.
Is there any other way ot handle this.
Please give your suggetions.
Thanks & Regards
Basant
-- modified at 8:13 Tuesday 29th November, 2005
|
|
|
|