|
I try to get some data from a .mdb file, but it fails with a realy weird and long exception, here is my code:
public DataSet getTranslation(int language)
{
DataSet translations = new DataSet();
String connes = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Johan\\My Documents\\languageDB1_00.mdb";
String sql = ("SELECT Translation, PhraseKey FROM Translation WHERE languageID = " + language + ";");
OleDbConnection conn = null;
conn = new OleDbConnection(connes);
//"SELECT Translation, PhraseKey FROM Translation WHERE languageID = " + language + ";";
try
{
OleDbCommand command = new OleDbCommand(sql, conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
conn.Open();
adapter.Fill(translations, "Translation");
return translations;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
return null;
}
finally
{
conn.Close();
}
}
The exeption message begins with:
IErrorInfo.GetDescription failed with E_FAIL (0x80004005)
please help...
john
|
|
|
|
|
Hello John,
The problem is because of the usage of the keyword "Translation" as in OLEDB.
If you change the SQL to
String sql = "(SELECT [Translation], PhraseKey FROM [Translation] " + <br />
"WHERE languageID = " + language + ")";
the snippet will work fine.
Regards
Mahesh
|
|
|
|
|
Hello folks,
i'm not a C# expert so i have a question to do.
I want to fetch the external ip of a machine whin is linked at a router.
All the HowTo i have seen didnt help me
If anyone can help I would be grateful.
Thanks
Enrico
|
|
|
|
|
I want to draw a triangle on the end of a line (vector).
I know how to do it brute force. Is there a better way?
Thanks a lot...
|
|
|
|
|
How would we know what "brute force" is to compare it to a better method? You have to post some code or supply some explanation of how you're doing it now. Also, the "best way" depends on the situation that the code is being used in. Do you need to draw this triangle in a certain position all the time, does it have to function as an arrow pointer, following the slope of the line? ???
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Point taken.
What I want is a triangle at the end of a line just as in the hands of a clock (it's not a clock).
By by "brute force", I meant a set of 3 connected points
Placed at the other end of the line.
|
|
|
|
|
Have you looked at the LineCap's of a Pen? Click[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Wow. I had no idea.... thanks. Not to get too greedy here, but is it possible to use it for the
technique here? Or will I have to re-write most of it.... thanks again
/////////////////////////////////////////////////////////////////////////////////////////////////////
public Pen[] activePen = new Pen[] { new Pen( Color.Blue, 2 ), new Pen( Color.Green, 2 ), new Pen(Color.Red, 2) };
private int _penIndex = -1;
/////////////////////////////////////////////////////////////////////////////////////////////////////////
private Pen GetNextPen()
{
_penIndex = (_penIndex + 1) % 3;
return activePen[_penIndex];
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
g.DrawLine(GetNextPen(), 250, 250, x, y );
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
Sure you can, but you will have to initialize the array of Pen somewhere else (for example in the constructor):
private Pen[] activePen;
public MyClass() {
activePen = new Pen[] { new Pen( Color.Blue, 2 ), new Pen( Color.Green, 2 ), new Pen(Color.Red, 2) };
activePen[0].EndCap = System.Drawing.Drawing2D.LineCap.Round;
activePen[1].EndCap = System.Drawing.Drawing2D.LineCap.Triangle;
activePen[2].StartCap = System.Drawing.Drawing2D.LineCap.Triangle;
activePen[3].EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
}
Now all your pens have different kind of caps. You can als play around with the other properties of the Pen (like Dash...). You should also look at the CustomeStartCap/EndCap properties. With them you can define special caps (if needed).
|
|
|
|
|
Hello,
in the help it says Varchar of the Type OleDBType is mapped to string of the .Net framework. How can i get this information if i have the OleDBType? because i can't find it anywhere this information.
greetings
Sander
|
|
|
|
|
Get what information?
The .Value of the OleDbParameter object? Easy, look at the .Value property.
What the OleDbTypes map to? This map doesn't exist in code. There are no hard-and-fast rules that "map" an OleDbType to a .NET Framework type. For example, you could read a database integer type into many types in the .NET Framework, depending on how you're using the data, an integer, single, double, byte, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
System.Data.DataTable tableSchema = Connection.GetOleDbSchemaTable( System.Data.OleDb.OleDbSchemaGuid.Columns, new object [ ] {null, null, t.name, null} );
System.Data.DataView dVTableSchema = new System.Data.DataView(tableSchema);
dVTableSchema.Sort = "ORDINAL_POSITION ASC";
for (int i=0; i < dVTableSchema.Count; i++)
{
int dataNumber = (int) dVTableSchema[i]["DATA_TYPE"];
System.Data.OleDb.OleDbType columnType = (System.Data.OleDb.OleDbType) Enum.Parse(new System.Data.OleDb.OleDbType().GetType(), dataNumber.ToString());
okej i have now the columType but know i wanna know how i can read the mapped .net type and i'm not using any oledbparameters.
greetings
Sander
|
|
|
|
|
There is NO MAPPED TYPE! The data can be moved to ANY .NET Framework value type.
The "mapping" is a set of guidelines, not a direct one-to-one relationship between the database type and any .NET Framework types.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hmm that sux because i need the base type so i need to translate it my self?
|
|
|
|
|
You have a problem. Say you read a floating point value from the database. Which .NET type are you going to map it to, Decimal (128-bits), Double (64-bits), Single (32-bits), integer, ...?
Yep. You have to pick an appropriate type to hold the value, since only YOU know what the range of that value should be and what precision you want it to be.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i'm a newbbie in programming, can somebody tell me how to create a program to monitor the bandwidth usage of each host within a network? Can System.Diagnostics.PerformanceCounter be used to monitor a remote computer?
|
|
|
|
|
Monitoring the bandwidth usage is best done by the switch the machine is connected to. If you do it over a remote connection using the Performance counters, you'll skew the usage statistics because transferring the counter information will add to the usage.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for your info Dave. By the way, What namespace or library do i need to investigate in order to write a bandwidth usage monitoring application? Do i need to create a client application and install it in the host machine within a network? the main function of my application will be monitoring the bandwidth usage of each machine within a LAN. And those machines are connected to internet through a router/switch/hub.
You mentioned that monitoring the bandwidth usage is best done by the switch the machinese is connected to. How can this be done? By monitoring every port of the switch? Can you tell me in details?
|
|
|
|
|
The switch already monitors all the ports, all you need to do is communicate with the switch to get the data, provided your switch can do this.
The problem with doing it in a client/server monitoring solution is that the usage will NEVER be 0. Even if the machine is not communicating with anything on the internet. This is because when the monitor starts, the usage will be 0, but will increase the second your client sends it "Heym my usage is 0" to the server. You'll get a steady "hum" from your monitoring software as is constantly sends usage data over the very network card it's monitoring.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How to communicate with the switch/router/hub to get the bandwidth usage data? Pls tell me in which field/namespace/library i need to study on. Thanks.
|
|
|
|
|
There isn't one. What you write depends entirely on how your particular switch, router, whatever exposes this information, if at all.
You'll will PROBABLY have to write a mini Telnet client into your app to get at this stuff.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Here my program:
#include <io.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
int main()
{
int bets, bets_made, bet_num[50], betmoney[50];
short roulette_choice, spinval;
double num_bets;
int betcheck = -1;
long cash = 500;
short bet = 0;
while ( !bet )
{
menumain: printf ( "\n\n\n *** Roulette ***\n" );
printf ( "(1): Place a bet\n" );
printf ( "(2): Check your cash\n" );
printf ( "(3): Mortage your house\n" );
printf ( "(4): Quit Roulette\n" );
printf ( "(5): Retire\n" );
printf ( "Please enter your choice: ");
scanf ( "%d", &roulette_choice );
switch (roulette_choice)
{
case 1: printf ( "\n\n\nHow many bets will you place?" );
scanf ( "%d", &num_bets );
num_bets = num_bets - 1;
bets_made = -1;
while (bets_made < num_bets)
{
bets_made++;
beginning:
printf ( "\nWhat number will you place a bet on (0-36)? " );
scanf ( "%d", &bet_num[bets_made] );
if ( 36 < bet_num[bets_made] || 0 > bet_num[bets_made] )
{
goto beginning;
}
printf ( "How much will you bet on number", "%d", &bet_num[bets_made], "?" );
scanf ( "%d", &betmoney[bets_made] );
}
bet= 1;
break;
case 2: printf ( "\n\nYou have $", "%d", &cash, "at this time." );
break;
case 3: printf ( "\n\nI think you need to go cool it for a while." );
return 0;
case 4: printf ( "\n\nReturning to the main menu now." );
return 0;
case 5: return 0;
default: printf ( "\n\nStay away from the bar for a while would ya?" );
goto menumain;
}
}
spinval = rand () %37;
printf ( "\n\n\nThe winning number is ", "%d", &spinval, "!" );
while (betcheck < num_bets )
{
betcheck ++;
if ( bet_num[betcheck] - spinval == 0 )
{
printf ( "\n\n\nYou won with the number ", "%d", &bet_num[betcheck], "!" );
cash = cash + (betmoney[betcheck] * (37.00/num_bets));
bet = betmoney[betcheck] * (37.00/(num_bets + 1));
printf ( "\nYou made $ ");
scanf ( "%d", &bet);
goto main;
}
}
printf ( "\n\nSorry pal, better luck next time\n" );
goto main;
}
Please tell me where is do mistake. Thank you.
|
|
|
|
|
You've got a lot to learn how forums work.
This is the C# forum, not C++.
All you've done is post your code and ask where the problem is. What problem? A description of what your expecting and what your seeing as the problem might help. Yes, I'm too lazy to cut and paste your code into a C++ project to see what it's doing.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i'm doing C Programming for the American Roulette. can u tell me da prob in my program? do u have some sample on roulette? can u send me please? thank you!!
|
|
|
|
|
I hate repeating myself.
YOU have to tell us what the problem is. We're not going to copy and paste your code into a project just to diagnose whatever problem you're not telling us about. What problem are we looking for?
Just posting your code and saying "it won't work" will NOT get you a solution to the problem.
You also have to post in the correct forum. You're posting this question in the C# Forum. You want the Visual C++[^] Forum.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|