|
There is also the Assembly.GetEntryAssembly() method.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
I am interested in a way, using the .NET Framework classes, to obtain a MAC address based on an IP number. Knowing an IP number, I need to know to extrapolate the MAC address. How can this be done with the .NET Framework and C#? I know that the MAC is not in the Request object, I need some guidance on getting the MAC *after* I have used the Request object to get the IP number. I have found some about using the "System.Management" Namespace already.
I'm assuming the machine running the function and the remote machine we are trying to obtain the physical address of are on the same network segment and are not separated by a firewall.
Any thoughts about a solution to the problem?
|
|
|
|
|
I don't think you can have the MAC address of a remote machine, at least not outside your network. This information is part of the physical transport layer, and is valid only with ethernet interfaces.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
As i wrote..
I'm assuming the machine running the function and the remote machine we are trying to obtain the physical address of are on the same network segment and are not separated by a firewall.
|
|
|
|
|
|
While ARP may be used to obtain the MAC address, a solution with the existing program arp.exe that is included with windows is not directly what I had in mind..
|
|
|
|
|
So what did you have in mind that my answer above didnt point you in the right direction for?
1) Get name of compuiter connecting to me using HTTP Request
2) Get MAC address of computer name from 1) using a method found on google
|
|
|
|
|
Hi all ..
I'm printing some images through PrintDocument.
I need to get the height in millimeters or centimeters before I send it to document. Is there any way of doing this? I have searched through graphics namesspace and only found ways om doing string measurements.
Pleae help
Regards // H
-- modified at 5:34 Friday 17th February, 2006
|
|
|
|
|
Hi,
I have a problem with my MySqlConnection in one of my programs.
When using the MySqlConnection object.
My 'system':
.Net 2.0
MySql 5.018
.NET Connector 1.07
Connection string: server=XXX.XXX.XX.XXX;database=XXX;user id=XXXX;pwd=XXXX; allow zero datetime=true; Protocol=TCP; Compress=false; Pooling=true; Min Pool Size=1; Max Pool Size=300; Connection Lifetime=0"
Everything works nicely a couple of times when I open the connection and do my queries (and close the connection).
But after (about the third time) the connection throws an exception when I try to open it:
Error:
System.ObjectDisposedException was unhandled
Message="Safe handle has been closed"
Source="System"
ObjectName=""
StackTrace:
at System.Net.UnsafeNclNativeMethods.OSSOCK.shutdown(SafeCloseSocket socketHandle, Int32 how)
at System.Net.Sockets.Socket.Shutdown(SocketShutdown how)
at ᐂ.Finalize()
Has anyone experienced this problem?
/// regards Patrik
|
|
|
|
|
Before typing to open your connection, check its .IsDisposed property. I suggest that under certain circumstances your code is disposing a connection and then trying to reuse it. This might be a race condition against a connection object, or it might be you trying to re-invent connection pooling - either of these sound possible?
|
|
|
|
|
Hi,
Thanks for the help!
I checked my code and I don't dispose the object. (I actually didn't find any .IsDisposed property for the connection object).
The code works really good for a number of tries and then suddenly it throws an exception. The error occurs very randomly.
"This might be a race condition against a connection object, or it might be you trying to re-invent connection pooling" - How can I check these issues?
I don't use any threads but I open and close the connection with the following code.
public static MySqlConnection Open()
{
try
{
MySqlConnection conn = new MySqlConnection(ConfigurationManager.AppSettings["MySqlConnectionString"].ToString());
conn.Open();
return conn;
}catch(Exception e){
string error = e.Message.ToString();
return null;
}
}
public static bool Close(MySqlConnection conn)
{
if (conn.State == System.Data.ConnectionState.Open)
{
try
{
conn.Close();
}
catch (Exception e)
{
string error = e.Message.ToString();
return false;
}
}
return true;
}
|
|
|
|
|
I have a problem
I'm busy writing a C#.NET project but walked into a problem.
I've got a Form With 3 Textboxes a Button and a DataGrid.
If i typ a value into the textboxes and i press the button. The datagrid Shows me the correct data.
the Selectcommand:
Select colom1, colum2, colom3, colom4, colom5
From Tabel1
Where (Colom1 = :param2)
and (Colom2 = :param3)
and (Colom3 = :param4)
But now i want it like This:
If i Typ a value for the first and last colom and nog the second one.
I still want him te show me the data he found.
If i do this now he says that he haven't got enough info to fill op my dataAdaptor.
Wich is logic.
But i realy don't have a clue how to do this.. can you help me?
-- modified at 6:33 Friday 17th February, 2006
|
|
|
|
|
Please anybody?? sigh:
|
|
|
|
|
What is the database, SQL Server?
I have done optional search parameters like this
CREATE PROCEDURE MySearch
@Param1 VARCHAR(50),
@Param2 VARCHAR(50)
AS
SELECT
COl1, Col2
FROM MyTable
WHERE Col1=CASE LEN(ISNULL(@Param1,'')
WHEN 0 THEN Col1
ELSE @Param1
END
AND Col2=CASE LEN(ISNULL(@Param2,'')
WHEN 0 THEN Col2
ELSE @Param2
END
|
|
|
|
|
I can't seem to find any method to programmatically set the list of selected items of a ListView (in Report view).
ListView.SelectedItems is a read-only list !?
I'm sure it can be done easyly but ....
/Jan
|
|
|
|
|
listView1.Items[0].Selected = true;
those who win are those who believe they can
|
|
|
|
|
I need the possibility to list available tables in MS Access and I just can't get it to work. I have tried the following lines of code but I don't get any useful information back.
public DataTable GetTables(OleDbConnection conn)
{
conn.Open();
DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] {null,null,null, "TABLE"});
conn.Close();
Is there anyone out there who got an idea of how to this?
Thanks
Andreas
|
|
|
|
|
Your code works for me
----------------------------
Be excellent to each other
|
|
|
|
|
How to import excel files into C#? And accessing it
s properties?
Thanks!
|
|
|
|
|
actually i want to create a reminder for user in my system. i managed tp create a reminder date (nextMaintDate). But now i want to compare the date today with nextMaintDate, if its found to be the same, the data will out into listview that i create. i already do the coding but there is problem with my query..this is my coding:
date = DateTime.Today;
string query = "SELECT equipmentName FROM equipment WHERE nextMaintDate >= date";
**help me please, im begineer with this. but im try to do it...huhuhu
|
|
|
|
|
Different databases want's different format of the date as input.
Ex VFP want the date as {^YYYY-MM-DD} (Swedish setting of windows)
Which kind of database are you using?
Andreas
|
|
|
|
|
i use mySql database...so, u have any idea?
|
|
|
|
|
According to this link: http://www.htmlite.com/mysql003.php the date format is YYYY-MM-DD.
Do the query like this:
select * from [table] where [field_date] > 2006-02-01
This should work. (Sorry, don't have any mySQL to test on)
Use the date conversion routines for taking todays date and convert it:
DateTime dt1 = DateTime.Now;
String date=dt1.Year.ToString()+"-"+dt1.Month.ToString(2,'0'+dt1.Day.ToString().PadLeft(2,'0');
Hope this will help
Andreas
|
|
|
|
|
string query = "SELECT equipmentName FROM equipment WHERE nextMaintDate >= DateTime.Now";
actually if i want to put it in this query, it is can or not..
i try already but it has a problem with DateTime.Now...so, i cant retrieve the data.
|
|
|
|
|
DateTime.Now is C#, interpreted by the compiler, while you need to pass an SQL query that will be interpreted by your database (MySql.)
If you will always be comparing to today's date and time, SQL Server has the GETDATE() function that returns the current date and time. I have never used MySql but it should have a similar function. A quick Goolge should do it.
Or you can pass the date/time from your application. The other reply suggested concatenation to build the SQL query, but there are many disadvantages to that, one being security (see this[^] article), and the other that you depend on the date format.
The correct way to do it is to use parameterized queries (as the above-mentioned article explains). That way you won't have security vulnerabilities, and you won't depend on the specific date format.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|