|
public static int GetIdentity(Person person){
Type type = person.GetType()
BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance
FieldInfo field = type.GetField("identity", flags)
Object value = field.GetValue(person)
return (int)value
}
I'm a wreck at C#, but i hope this helps!
|
|
|
|
|
For anyone working their way through the Que Certification for exam 316 there is an error in exercise 2.18. For the code to work correctly you will need to add a using System.IO directive otherwise you will not be able to compile the code.
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
How do I develop my C# project into a stand alone software that can run on any computer?
|
|
|
|
|
fire up vs and select new visual c# project then choose the "Windows Application" Template. That will create your stand alone software.
|
|
|
|
|
But I face problems when i try to run the application in computers that do not have visual studio .net.
|
|
|
|
|
.Net apps need the .Net framework to run.
Maybe those computers don't have that framework.
If that is the case, you can download it here[^].
|
|
|
|
|
Is it possible to run a visual C# windows application project on a computer that does not have visual studio?
|
|
|
|
|
|
Yes, of course. It's NOT possible to run it on a machine that doesn't run the .NET framework, as has been pointed out.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Could use someone to double check my work here, looking for unnecessary info, unneeded commands, broken or missing thoughts...meaning did i start somthing but forgot to finish it. and any security violations or leaks that may exist.
I've gotten so far into this that my flow charts are now circles and i've re-written it twice(flowchart). I'm looking for someone or many someones' who would be willing to check it out....
Please note that my desired result is a software program that does not load on any computer that is not allowed for it to load on.
I am attempting to do this by contacting the database and looking for a keyword....if the keyword is missing then it doesn't install.
the keyword is deleted by the software program upon install (yes i understand that i'll have to re apply the keyword upon every new install, i want that!)
then i want every login from the software to log a transaction, as well identify itself on a user id table upon the intial installation.
info about my code:
fp.Value makes a machine id number that is unique for each pc.
InitializeComponent2 is a form that tells the user they've screwed up and closes the app
Connection is the method that loads my treeView from the database
Yes the typeset small, but i didn't want to take up more space than needed.
it should copy over ok.
thanks!!!
<small> DateTime dt = DateTime.Now;
string usename = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
string sqlSelect = "SELECT password FROM user_id WHERE username = 'dash' ";
private void dbConnect()
{
dataConnection.ConnectionString = "user ID=blah;Pwd=blah;Initial Catalog=blah;Data Source=blah";
dataConnection.Open();
dataCommand.Connection = dataConnection;
}
private void InitialTransAxs()
{
this.Cursor = Cursors.WaitCursor;
Fingerprint fp = new Fingerprint();
string MacID = fp.Value().ToString();
try
{
string shostname;
string result;
result = System.Environment.MachineName;
shostname = Dns.GetHostName().ToString();
dataCommand.CommandText = "insert into user_id (username, password, computer_name, dns_name) values ('" + usename + "', '" + MacID + "', '"+ result +"', '" + shostname + "')";
dataCommand.ExecuteNonQuery();
dataCommand.CommandText = "update user_id set password = null where username = 'dash'";
dataCommand.ExecuteNonQuery();
this.Cursor = Cursors.Default;
}
catch (Exception e)
{
MessageBox.Show("(001) Sorry Could not connect to the database, please try again later." +e.Message + e.StackTrace);
}
finally
{
}
}
private void LogTransAxs()
{
this.Cursor = Cursors.WaitCursor;
Fingerprint fp = new Fingerprint();
string MacID = fp.Value().ToString();
string shostname;
string result;
try
{
result = System.Environment.MachineName;
shostname = Dns.GetHostName().ToString();
dataCommand.CommandText = "insert into TransAxs (username, password, computer_name, dns_name, date) values ('" + usename + "', '" + MacID + "', '"+ result +"', '" + shostname + "','"+ dt +"')";
dataCommand.ExecuteNonQuery();
}
catch (Exception es)
{
MessageBox.Show("(002) Sorry Could not connect to the database, please try again later." +es.Message +es.StackTrace);
}
}
private void LoadAccess()
{
this.Cursor = Cursors.WaitCursor;
Fingerprint fp = new Fingerprint();
dbConnect();
dataCommand.CommandText = sqlSelect;
try
{
bool loginOk = false;
bool IdOK = false;
object o = dataCommand.ExecuteScalar();
string thePwd = o as string;
if( thePwd != null)
{
if( thePwd.Equals("board"))
{
loginOk = true;
}
}
if(loginOk == true)
{
InitialTransAxs();
LogTransAxs();
InitializeComponent();
Connection();
dataConnection.Close();
dataConnection.Dispose();
}
else if (loginOk == false)
{
dataCommand.CommandText = "SELECT password FROM user_id WHERE password = '"+ fp.Value() +"' ";
object p = dataCommand.ExecuteScalar();
if (p != null)
{
if (p.Equals(fp.Value().ToString()))
{
IdOK = true;
}
}
if (IdOK == true)
{
LogTransAxs();
InitializeComponent();
Connection();
}
else
{
InitializeComponent2();
dataConnection.Close();
dataConnection.Dispose();
}
}
else
{
InitializeComponent2();
dataConnection.Close();
dataConnection.Dispose();
}
}
catch (Exception e)
{
MessageBox.Show("(003) Sorry you are not authorized to view this material." +e.Message +e.StackTrace);
}
finally
{
dataConnection.Close();
dataConnection.Dispose();
}
this.Cursor = Cursors.Default;
</small>
Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."
Why is common sense such an un-common comodity?
|
|
|
|
|
Hi
i work in a project about database and use datagrid . i want to prevent user from adding new record ( by clicking the * sign in datagrid ) but i can not find anything like allowAdd or CanAdd for disabling the add ability .
can someone help me ?
Regards Amir Jalaly
|
|
|
|
|
The DataGrid class does not have a property that controls whether a new row can be added. But the DataView class does have such a property (along with some others such as AllowEdit and AllowDelete). Here is code that will turn off the append row by getting at the dataview associated with the datagrid.
string connString = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb";
string sqlString = "SELECT * FROM customers";
// Connection object
OleDbConnection connection = new OleDbConnection(connString);
// Create data adapter object
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sqlString, connection);
// Create a dataset object and fill with data using data adapter's Fill method
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet, "customers");
// Attach dataset's DefaultView to the datagrid control
dataGrid1.DataSource = dataSet.Tables["customers"];
//no adding of new rows thru dataview...
CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];
((DataView)cm.List).AllowNew = false;
If your datagrid contains links, then adding Navigate handler such as the one below to disallow the AddNew.
private void DataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
if(ne.Forward)
{
CurrencyManager cm = (CurrencyManager)BindingContext[DataGrid1.DataSource,DataGrid1.DataMember];
DataView dv = (DataView) cm.List;
dv.AllowNew = false;
}
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
In the article “Bending the .NET PropertyGrid to Your Will” , “Fruit enum” is define at design time and therefore the selection for property in to the PropertyGrid allow to select one of them. Is it possible to get the values form database on the fly and and allow user to select one of them.
Best Regards,
Hardew Singh
|
|
|
|
|
I suppose you could, but I don't really know how. I haven't used property grids yet.
I'll suggest you post this question in the article's own message board. You'll probably get better answers (including from the author, who knows a lot about his article (I suppose )).
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
It's been awhile since I've been deep into the property grids but yes you can do what you want to do. For valid values (which is what you talk about) there is a GetProperties() method or something like that that you override. You return the list of valid values in that call which can be from a database. Look at this article to get specifics.
MSDN Article on property grids[^]
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
Yes it is Resize but is happen also if i resize manually the form, but i need to understand if the user has clicked on the maximize button.
How?
|
|
|
|
|
I am not sure if such an event is available but in the SizeChange event you
can check for
if ( this.WindowState == FormWindowState.Maximized )
{
...
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
|
Hi there. I'm running this website www.elefun.net for my company. It is an C# .net solution.
Most of the website/product information and user information is based on an Access db. I've got some negative comments about Access db's like:
1. Access db's are bad and should not be used.
2. Access do not handle large db's well.
So I've been considering to change to an SQL db for I while, but I really don't know if it's nesessary. My Access db is at the moment about 9MB. My questions are:
3. Is it OK to use acces db's for this kind of solutions?
4. Does Access db's get to large. If they do? When are they to large? 10MB, 100MB, 1GB. I really don't have any clue.
5. Is converting from an Access to an SQL db hard? I've worked some with both kinds of db's, but never tried converting between them. Will I have to do many changes in my solution, or will changing the db connection be it?
|
|
|
|
|
Access is a database meant for desktop use. It's not meant to be used in a web environment. Since Access databases don't compact themselves, with continued use, your database will get bigger and bigger over time. You'll have to shut down your website, launch Access, or some other tool, compact and repair the database, then bring your website back up.
Think about it. You're using a website that has the possiblity of growing. An Access database will be a large bottoneck in the performance of your site, should it get the traffic.
It's relatively easy to upsize an Access database to SQL Server. There's a tool built into Access to do it. It's just that what is generated by the tool might not be the best performing SQL. It's a decent short term solution, but you'd probably be better off re-writing for SQL Server by hand.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
1. Access is sometimes convenient, and works well if the demands of the application are not too great.
2. Depends on what you mean by "large".
3. I don't know. I have not used Access in a web application. I know that in a non web server environment that the more simultaneous users you have, and the larger the db, the more corruption problems I have had. I don't know if the same applies in a web app since there will probably only be 1 user (network Service account in win 2k3).
4. I did not have much problem until the database size exceeded at least 500MB or maybe a little larger. I had many corruption problems by the time the db reached 1GB. This was with about 10 to 15 simultaneous users with the mdb file on a network share.
5. It should not be too difficult to convert. I haven't worked with Access in a .Net environment, but in the old days, the date fields required slightly different delimiters than SQL Server.
Note: All my Access experience was with Access 97 using old ADO. I have not used Access in about 3 years.
|
|
|
|
|
4. The hard limit is at 2GB. But be warned: Regulary inserting and deleting in an Access db will result in a growing file. So even if you have 9 Mb of content your file can get a size beyond the 2 Gb limit.
|
|
|
|
|
Thanks for the help by all of you. It seems like I'll continue use the access db for a while. Then I'll have the time do develop a good alternative SQL db for later use.
About the growing size of the Acces db whenit's used. Will this growth be seen as the filesize so I can monitor the size by checking the file by FTP or other?
If my Access db need to be cleaned up. How do I do it? If the growth in size is caused by use, and not data...
|
|
|
|
|
Hi,
Just a quick question. Let's say I have the WebSphere MQ .NET libraries installed on my local machine, and in my C# code I use the directive 'using IBM.WMQ;'. Everything compiles successfully & runs well on my machine. But what happens when I run the app on another machine, one which may not have WebSphere installed? Will the executable error? Is there some way I can customize this error, perhaps by checking if a library is available before 'using' it in my C# code?
Thanks in advance,
Andrew
|
|
|
|