|
You've been loading text files, and you want to move to an Access DB ? If you google[^] C# Access Database, you get heaps of links to articles on this sort of thing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi there,
if u need to keep the records in Access DB, u need to have basic knowledge of mechanism of accessing to Access DB, such as: ODBC, OleDB, ADO or ADO.NET.
u can get more detail and also simple codes from MSDN
To query from Access DB, u also need to know SQL query. This can be got from SQL Book Online
<< >>
|
|
|
|
|
Hi hi,
If it's using oledbadapter and dataset, i know how to use them and query for data from Access.
However, what i need now is how do i automatically store the data downloaded into Access instead of storing in Notepad?
How do i get every set of downloaded data to append to my Access db table??
Thank you!!
|
|
|
|
|
after u downloaded data need to be stored into Access DB, u can use sql query that is something like "insert into ur table(field1, field2,..) values (...)" to insert the data into Access DB
<< >>
|
|
|
|
|
See the FunA() and FunB() result, why any diffent?
<br />
private void FunA()<br />
{<br />
double value;<br />
System.Text.StringBuilder sb = new System.Text.StringBuilder();<br />
for( value = 2.1; value >= -1.1; value -= 0.1 )<br />
sb.AppendFormat("Ceiling({0:f})={1} Floor({0:f})={2} Round({0:f})={3} (int)({0:f}+0.5)={4} Truncate({0:f})={5}\n", value, Math.Ceiling(value), Math.Floor(value), Math.Round(value), (int)(value+0.5), Decimal.Truncate(Convert.ToDecimal(value)));<br />
return sb.ToString();<br />
}<br />
private string FunB()<br />
{<br />
double value;<br />
System.Text.StringBuilder sb = new System.Text.StringBuilder();<br />
for( value = 5.1; value >= -1.1; value -= 0.1 )<br />
sb.AppendFormat("Ceiling({0:f})={1} Floor({0:f})={2} Round({0:f})={3} (int)({0:f}+0.5)={4} Truncate({0:f})={5}\n", value, Math.Ceiling(value), Math.Floor(value), Math.Round(value), (int)(value+0.5), Decimal.Truncate(Convert.ToDecimal(value)));<br />
return sb.ToString();<br />
}<br />
Reuslts is:
FunA():
Ceiling(2.10)=3 Floor(2.10)=2 Round(2.10)=2 (int)(2.10+0.5)=2 Truncate(2.10)=2
Ceiling(2.00)=2 Floor(2.00)=2 Round(2.00)=2 (int)(2.00+0.5)=2 Truncate(2.00)=2
Ceiling(1.90)=2 Floor(1.90)=1 Round(1.90)=2 (int)(1.90+0.5)=2 Truncate(1.90)=1
Ceiling(1.80)=2 Floor(1.80)=1 Round(1.80)=2 (int)(1.80+0.5)=2 Truncate(1.80)=1
Ceiling(1.70)=2 Floor(1.70)=1 Round(1.70)=2 (int)(1.70+0.5)=2 Truncate(1.70)=1
Ceiling(1.60)=2 Floor(1.60)=1 Round(1.60)=2 (int)(1.60+0.5)=2 Truncate(1.60)=1
Ceiling(1.50)=2 Floor(1.50)=1 Round(1.50)=1 (int)(1.50+0.5)=1 Truncate(1.50)=1
Ceiling(1.40)=2 Floor(1.40)=1 Round(1.40)=1 (int)(1.40+0.5)=1 Truncate(1.40)=1
Ceiling(1.30)=2 Floor(1.30)=1 Round(1.30)=1 (int)(1.30+0.5)=1 Truncate(1.30)=1
Ceiling(1.20)=2 Floor(1.20)=1 Round(1.20)=1 (int)(1.20+0.5)=1 Truncate(1.20)=1
Ceiling(1.10)=2 Floor(1.10)=1 Round(1.10)=1 (int)(1.10+0.5)=1 Truncate(1.10)=1
Ceiling(1.00)=1 Floor(1.00)=0 Round(1.00)=1 (int)(1.00+0.5)=1 Truncate(1.00)=0
Ceiling(0.90)=1 Floor(0.90)=0 Round(0.90)=1 (int)(0.90+0.5)=1 Truncate(0.90)=0
Ceiling(0.80)=1 Floor(0.80)=0 Round(0.80)=1 (int)(0.80+0.5)=1 Truncate(0.80)=0
Ceiling(0.70)=1 Floor(0.70)=0 Round(0.70)=1 (int)(0.70+0.5)=1 Truncate(0.70)=0
Ceiling(0.60)=1 Floor(0.60)=0 Round(0.60)=1 (int)(0.60+0.5)=1 Truncate(0.60)=0
Ceiling(0.50)=1 Floor(0.50)=0 Round(0.50)=0 (int)(0.50+0.5)=0 Truncate(0.50)=0
Ceiling(0.40)=1 Floor(0.40)=0 Round(0.40)=0 (int)(0.40+0.5)=0 Truncate(0.40)=0
Ceiling(0.30)=1 Floor(0.30)=0 Round(0.30)=0 (int)(0.30+0.5)=0 Truncate(0.30)=0
Ceiling(0.20)=1 Floor(0.20)=0 Round(0.20)=0 (int)(0.20+0.5)=0 Truncate(0.20)=0
Ceiling(0.10)=1 Floor(0.10)=0 Round(0.10)=0 (int)(0.10+0.5)=0 Truncate(0.10)=0
Ceiling(0.00)=0 Floor(0.00)=-1 Round(0.00)=0 (int)(0.00+0.5)=0 Truncate(0.00)=0
Ceiling(-0.10)=0 Floor(-0.10)=-1 Round(-0.10)=0 (int)(-0.10+0.5)=0 Truncate(-0.10)=0
Ceiling(-0.20)=0 Floor(-0.20)=-1 Round(-0.20)=0 (int)(-0.20+0.5)=0 Truncate(-0.20)=0
Ceiling(-0.30)=0 Floor(-0.30)=-1 Round(-0.30)=0 (int)(-0.30+0.5)=0 Truncate(-0.30)=0
Ceiling(-0.40)=0 Floor(-0.40)=-1 Round(-0.40)=0 (int)(-0.40+0.5)=0 Truncate(-0.40)=0
Ceiling(-0.50)=0 Floor(-0.50)=-1 Round(-0.50)=-1 (int)(-0.50+0.5)=0 Truncate(-0.50)=0
Ceiling(-0.60)=0 Floor(-0.60)=-1 Round(-0.60)=-1 (int)(-0.60+0.5)=0 Truncate(-0.60)=0
Ceiling(-0.70)=0 Floor(-0.70)=-1 Round(-0.70)=-1 (int)(-0.70+0.5)=0 Truncate(-0.70)=0
Ceiling(-0.80)=0 Floor(-0.80)=-1 Round(-0.80)=-1 (int)(-0.80+0.5)=0 Truncate(-0.80)=0
Ceiling(-0.90)=0 Floor(-0.90)=-1 Round(-0.90)=-1 (int)(-0.90+0.5)=0 Truncate(-0.90)=0
Ceiling(-1.00)=-1 Floor(-1.00)=-2 Round(-1.00)=-1 (int)(-1.00+0.5)=0 Truncate(-1.00)=-1
FuncB():
Ceiling(5.10)=6 Floor(5.10)=5 Round(5.10)=5 (int)(5.10+0.5)=5 Truncate(5.10)=5
Ceiling(5.00)=5 Floor(5.00)=5 Round(5.00)=5 (int)(5.00+0.5)=5 Truncate(5.00)=5
Ceiling(4.90)=5 Floor(4.90)=4 Round(4.90)=5 (int)(4.90+0.5)=5 Truncate(4.90)=4
Ceiling(4.80)=5 Floor(4.80)=4 Round(4.80)=5 (int)(4.80+0.5)=5 Truncate(4.80)=4
Ceiling(4.70)=5 Floor(4.70)=4 Round(4.70)=5 (int)(4.70+0.5)=5 Truncate(4.70)=4
Ceiling(4.60)=5 Floor(4.60)=4 Round(4.60)=5 (int)(4.60+0.5)=5 Truncate(4.60)=4
Ceiling(4.50)=5 Floor(4.50)=4 Round(4.50)=5 (int)(4.50+0.5)=5 Truncate(4.50)=4
Ceiling(4.40)=5 Floor(4.40)=4 Round(4.40)=4 (int)(4.40+0.5)=4 Truncate(4.40)=4
Ceiling(4.30)=5 Floor(4.30)=4 Round(4.30)=4 (int)(4.30+0.5)=4 Truncate(4.30)=4
Ceiling(4.20)=5 Floor(4.20)=4 Round(4.20)=4 (int)(4.20+0.5)=4 Truncate(4.20)=4
Ceiling(4.10)=5 Floor(4.10)=4 Round(4.10)=4 (int)(4.10+0.5)=4 Truncate(4.10)=4
Ceiling(4.00)=5 Floor(4.00)=4 Round(4.00)=4 (int)(4.00+0.5)=4 Truncate(4.00)=4
Ceiling(3.90)=4 Floor(3.90)=3 Round(3.90)=4 (int)(3.90+0.5)=4 Truncate(3.90)=3
Ceiling(3.80)=4 Floor(3.80)=3 Round(3.80)=4 (int)(3.80+0.5)=4 Truncate(3.80)=3
Ceiling(3.70)=4 Floor(3.70)=3 Round(3.70)=4 (int)(3.70+0.5)=4 Truncate(3.70)=3
Ceiling(3.60)=4 Floor(3.60)=3 Round(3.60)=4 (int)(3.60+0.5)=4 Truncate(3.60)=3
Ceiling(3.50)=4 Floor(3.50)=3 Round(3.50)=4 (int)(3.50+0.5)=4 Truncate(3.50)=3
Ceiling(3.40)=4 Floor(3.40)=3 Round(3.40)=3 (int)(3.40+0.5)=3 Truncate(3.40)=3
Ceiling(3.30)=4 Floor(3.30)=3 Round(3.30)=3 (int)(3.30+0.5)=3 Truncate(3.30)=3
Ceiling(3.20)=4 Floor(3.20)=3 Round(3.20)=3 (int)(3.20+0.5)=3 Truncate(3.20)=3
Ceiling(3.10)=4 Floor(3.10)=3 Round(3.10)=3 (int)(3.10+0.5)=3 Truncate(3.10)=3
Ceiling(3.00)=4 Floor(3.00)=3 Round(3.00)=3 (int)(3.00+0.5)=3 Truncate(3.00)=3
Ceiling(2.90)=3 Floor(2.90)=2 Round(2.90)=3 (int)(2.90+0.5)=3 Truncate(2.90)=2
Ceiling(2.80)=3 Floor(2.80)=2 Round(2.80)=3 (int)(2.80+0.5)=3 Truncate(2.80)=2
Ceiling(2.70)=3 Floor(2.70)=2 Round(2.70)=3 (int)(2.70+0.5)=3 Truncate(2.70)=2
Ceiling(2.60)=3 Floor(2.60)=2 Round(2.60)=3 (int)(2.60+0.5)=3 Truncate(2.60)=2
Ceiling(2.50)=3 Floor(2.50)=2 Round(2.50)=3 (int)(2.50+0.5)=3 Truncate(2.50)=2
Ceiling(2.40)=3 Floor(2.40)=2 Round(2.40)=2 (int)(2.40+0.5)=2 Truncate(2.40)=2
Ceiling(2.30)=3 Floor(2.30)=2 Round(2.30)=2 (int)(2.30+0.5)=2 Truncate(2.30)=2
Ceiling(2.20)=3 Floor(2.20)=2 Round(2.20)=2 (int)(2.20+0.5)=2 Truncate(2.20)=2
Ceiling(2.10)=3 Floor(2.10)=2 Round(2.10)=2 (int)(2.10+0.5)=2 Truncate(2.10)=2
Ceiling(2.00)=3 Floor(2.00)=2 Round(2.00)=2 (int)(2.00+0.5)=2 Truncate(2.00)=2
Ceiling(1.90)=2 Floor(1.90)=1 Round(1.90)=2 (int)(1.90+0.5)=2 Truncate(1.90)=1
Ceiling(1.80)=2 Floor(1.80)=1 Round(1.80)=2 (int)(1.80+0.5)=2 Truncate(1.80)=1
Ceiling(1.70)=2 Floor(1.70)=1 Round(1.70)=2 (int)(1.70+0.5)=2 Truncate(1.70)=1
Ceiling(1.60)=2 Floor(1.60)=1 Round(1.60)=2 (int)(1.60+0.5)=2 Truncate(1.60)=1
Ceiling(1.50)=2 Floor(1.50)=1 Round(1.50)=2 (int)(1.50+0.5)=2 Truncate(1.50)=1
Ceiling(1.40)=2 Floor(1.40)=1 Round(1.40)=1 (int)(1.40+0.5)=1 Truncate(1.40)=1
Ceiling(1.30)=2 Floor(1.30)=1 Round(1.30)=1 (int)(1.30+0.5)=1 Truncate(1.30)=1
Ceiling(1.20)=2 Floor(1.20)=1 Round(1.20)=1 (int)(1.20+0.5)=1 Truncate(1.20)=1
Ceiling(1.10)=2 Floor(1.10)=1 Round(1.10)=1 (int)(1.10+0.5)=1 Truncate(1.10)=1
Ceiling(1.00)=2 Floor(1.00)=1 Round(1.00)=1 (int)(1.00+0.5)=1 Truncate(1.00)=1
Ceiling(0.90)=1 Floor(0.90)=0 Round(0.90)=1 (int)(0.90+0.5)=1 Truncate(0.90)=0
Ceiling(0.80)=1 Floor(0.80)=0 Round(0.80)=1 (int)(0.80+0.5)=1 Truncate(0.80)=0
Ceiling(0.70)=1 Floor(0.70)=0 Round(0.70)=1 (int)(0.70+0.5)=1 Truncate(0.70)=0
Ceiling(0.60)=1 Floor(0.60)=0 Round(0.60)=1 (int)(0.60+0.5)=1 Truncate(0.60)=0
Ceiling(0.50)=1 Floor(0.50)=0 Round(0.50)=1 (int)(0.50+0.5)=1 Truncate(0.50)=0
Ceiling(0.40)=1 Floor(0.40)=0 Round(0.40)=0 (int)(0.40+0.5)=0 Truncate(0.40)=0
Ceiling(0.30)=1 Floor(0.30)=0 Round(0.30)=0 (int)(0.30+0.5)=0 Truncate(0.30)=0
Ceiling(0.20)=1 Floor(0.20)=0 Round(0.20)=0 (int)(0.20+0.5)=0 Truncate(0.20)=0
Ceiling(0.10)=1 Floor(0.10)=0 Round(0.10)=0 (int)(0.10+0.5)=0 Truncate(0.10)=0
Ceiling(0.00)=1 Floor(0.00)=0 Round(0.00)=0 (int)(0.00+0.5)=0 Truncate(0.00)=0
Ceiling(-0.10)=0 Floor(-0.10)=-1 Round(-0.10)=0 (int)(-0.10+0.5)=0 Truncate(-0.10)=0
Ceiling(-0.20)=0 Floor(-0.20)=-1 Round(-0.20)=0 (int)(-0.20+0.5)=0 Truncate(-0.20)=0
Ceiling(-0.30)=0 Floor(-0.30)=-1 Round(-0.30)=0 (int)(-0.30+0.5)=0 Truncate(-0.30)=0
Ceiling(-0.40)=0 Floor(-0.40)=-1 Round(-0.40)=0 (int)(-0.40+0.5)=0 Truncate(-0.40)=0
Ceiling(-0.50)=0 Floor(-0.50)=-1 Round(-0.50)=0 (int)(-0.50+0.5)=0 Truncate(-0.50)=0
Ceiling(-0.60)=0 Floor(-0.60)=-1 Round(-0.60)=-1 (int)(-0.60+0.5)=0 Truncate(-0.60)=0
Ceiling(-0.70)=0 Floor(-0.70)=-1 Round(-0.70)=-1 (int)(-0.70+0.5)=0 Truncate(-0.70)=0
Ceiling(-0.80)=0 Floor(-0.80)=-1 Round(-0.80)=-1 (int)(-0.80+0.5)=0 Truncate(-0.80)=0
Ceiling(-0.90)=0 Floor(-0.90)=-1 Round(-0.90)=-1 (int)(-0.90+0.5)=0 Truncate(-0.90)=0
Ceiling(-1.00)=0 Floor(-1.00)=-1 Round(-1.00)=-1 (int)(-1.00+0.5)=0 Truncate(-1.00)=0
Ceiling(-1.10)=-1 Floor(-1.10)=-2 Round(-1.10)=-1 (int)(-1.10+0.5)=0 Truncate(-1.10)=-1
Diffrents are showed in bold font.
Why same procedure, only diffrent value of starter, but has many diffrent? Float is so wonder, how can i make it exact.
=== Game is power! ===
|
|
|
|
|
Use double or Decimal, they are more precise.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
It already is double!
=== Game is power! ===
|
|
|
|
|
OK, then try Decimal. Floating point isn't precise, that's just how it is. 1.5 + .5 is probably 1.999999, and then casting always rounds down.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You can't make it exact using a floating point data type. A floating poing value is often not exactly the value you specify, as some values can not be represented exactly.
For an example, the value 2.00 might actually be 2.000000000000001, and using Math.Ceiling() on that value will result in the value 3.0.
---
b { font-weight: normal; }
|
|
|
|
|
I see. So that's say I can not get a very exact float value.
But the other question is why the procedure is same, only diffrent between the begining value and loop times, it will make this difrrent.
As you said, every time Math.Ceiling(2.00) must equal 3, but why in FunA() it is equal 2.
They all are called by Math.Ceiling(value) and the value=2.00, the very small gap can not explain this result.
=== Game is power! ===
|
|
|
|
|
.1 cannot be represented in binary, as a result when the 2nd loop should reach the same value the first one starts at, it actually different at the last few decimal places and will either be slightly above, or slightly below the expected value.
|
|
|
|
|
You start at different values. When you get to 2.00, you have made a different amount of adds, so the accumulative error is different. That's why the result differs.
---
b { font-weight: normal; }
|
|
|
|
|
196805 :PrintMon.exe Demonstrates the Win32 Spooler API
If I don't select use printer notication,I can get the monitor information (what I had printed )from network printer.
but if I select use printer notications ,I can't get the monitor information from network printer.
sometimes it show error info is: the handle is invalid(FindNextPrinterChangeNotification)
why?
my operate system is window xp
thanks
-- modified at 21:46 Tuesday 13th September, 2005
|
|
|
|
|
i'm not shure how to go about writing the code for this i need help!!!!!!!
it has 2 group boxes,,,, ,groupbox 1 has name and message labels in it as well as 2 text boxes,
groupbox 2 is directley under groupbox 1,groupbox 2 is labeled (color)
it has 4 radio buttons with red,green, blue ,and black.
it also has a picture box at the lower left corner. and 2 more labels 1 under the pic box and the other to the right of the pic box
|
|
|
|
|
what is the question?
MCAD
|
|
|
|
|
i'm just starting to use c# i'm not shure how to start the code . i know what it should look like but not shure how to put into code...
any help would be apprciated
|
|
|
|
|
Hi,
I am writing an application that needs to "take over" another window that runs a streaming data. I mean, I have a streamer, which shows some data on the screen, and I need to write a program that can read this data from the screen, analyze certain things and then press some buttons on this streamer. My prefference was really to write this in java,(can be in C# though) but I can't find a way or direction as to how I can read or control another application window. Does anyone can please show me at least a hint or refference ? I might add that this should run under windows XP and with administrator authorizations.
Thanks.
|
|
|
|
|
If i understood you correctly you want to achive two things First make two application communicate with each other.Second make one appliaction press buttons in another application if this correct for first use one of Inter-Process Communication like remoting,winsockets...
look at Threads[^]
for the seconed you can achive it using SendMessage windows api an example you can found it Click Buttons in another apllication[^]
second way you can define your custom protocol so let one application to send message to another to call specific method
MCAD
|
|
|
|
|
Hi all
I'm trying to implement a form that can only display one instance at a time. Note that this isn't the first form of the application - I'm not trying to build a single instance app. I just want one of the forms to display only once when a button on the form called at startup is clicked. I've got this working for the most part by implementing it as a singleton but run into problems when the form is closed and I try to open it by clicking the button again. The code I'm using is:
public partial class Singleton : Form
{
private static Singleton instance = null;
private Singleton()
{
InitializeComponent();
}
public static Singleton Instance
{
get
{
if (instance == null)
{
instance = new Singleton();
}
return instance;
}
}
~ Singleton()
{
instance = null;
}
}
I was under the impression that the destructor would resolve the issue I'm having but it hasn't. I receive the following exception:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Singleton'.
Could anyone suggest how I can resolve this issue or suggest another approach to a single instance form that can be launched and closed more than once from the main form of the app?
Thanks in advance
MrR_
Nothing is foolproof to the talented fool.
|
|
|
|
|
A possible solution would be to create the form at startup, and only Show() /Hide() . When the button is pressed, Show() , and attach to the Form.Closing event and instead of destroying the form, simply Hide() it.
|
|
|
|
|
May this help
public class SingletonForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private static SingletonForm formInstance;
public SingletonForm()
{
InitializeComponent();
}
public static SingletonForm GetInstance()
{
if(formInstance!=null)
return formInstance;
else
return (formInstance =new SingletonForm());
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "SingletonForm";
}
protected override void OnClosing(CancelEventArgs e)
{
e.Cancel=true;
this.Hide();
}
}
look at Singleton Pattern[^]
MCAD
|
|
|
|
|
Hi again
Thanks for the tips so far. I'd actually come across those myself but I want to do a lot of work when the form opens and closes that hide introduces problems for. I'll admit that I can probably work around this with a lot of effort. I was just hoping there might be an elegant solution.
Thanks
MrR_
Nothing is foolproof to the talented fool.
|
|
|
|
|
Hi all,
I'm making a little dictionary program in C# for experimenting purposes. everything is coming along fine except how to select the word that is currently under the mouse when the user presses.
in VB6 it was done through an API as i remember, but i don't recall which, but this shold be a .net framework program, so better without any win32 api
Thanks in advance
|
|
|
|
|
If You use RichTextBox you can use GetCharIndexFromPosition to get the word
this simple example
private string GetWordFromPos(Point p)
{
string word;
int cIdx=richTextBox1.GetCharIndexFromPosition(p);
int startPos;
for(startPos=cIdx;startPos>0;startPos--)
{
string c=richTextBox1.Text.Substring(startPos-1,1);
if(c == " ")
break;
}
word=richTextBox1.Text.Substring(startPos,cIdx-startPos);
for(startPos=cIdx;startPos<richTextBox1.Text.Length;startPos++)
{
string c=richTextBox1.Text.Substring(startPos,1);
if(c == " ")
break;
}
word+=richTextBox1.Text.Substring(cIdx,startPos-cIdx);
return word;
}
private void richTextBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point p=new Point(e.X,e.Y);
String word=GetWordFromPos(p);
Debug.WriteLine(word);
}
If you use TextBox then TextBox didn't have equivalent method or as i know so you need to use SendMessage Windows API to Function to send EM_CHARFROMPOS to get the index of the Char and Modify the previous function to take to get the text for more inf o look at
EM_CHARFROMPOS Message [^]
MCAD
-- modified at 22:30 Tuesday 13th September, 2005
|
|
|
|
|
The problem is, I want to use this function on the text in other windows, not in my program. and i can't be sure if it'll be a rich textbox, textbox, label or any other control that will be read.
I read the "EM_CHARFROMPOS Message" but it makes little sense to me. high word, low word... it all doesn't sound the c# level. was that in the C++ time?
|
|
|
|