|
Hi.
My friend and I are very new to C#, we would like to start a project in C# together.
We have Team foundation server 2005 beta2 from microsoft, but can't install it because of known issues.
Until the final is released, we decided to continue without it.
We created a ASP.Net webpage where he edits the frontend (site.aspx) and backend (site.aspx.cs) while i have added a new page to the project called newstuff.cs (in a subfolder called App_code)
If i make a method called CalculateDistance(), how do i include it in the main project page (site.aspx.cs) ?
I have some code like this:
<br />
using System.Net;<br />
using System.Runtime.InteropServices;<br />
[DllImport("iphlpapi.dll", ExactSpelling = true)]<br />
public static extern int SendARP(int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen);<br />
<br />
String LocalHostName = Dns.GetHostName();<br />
string[] Ipaddr = new string[3];<br />
Ipaddr[0] = LocalHostName;<br />
System.Net.IPHostEntry LocalIpAddress = Dns.GetHostEntry(LocalHostName);<br />
System.Net.IPAddress[] FirstAddress = LocalIpAddress.AddressList;<br />
foreach (IPAddress TempA in FirstAddress)<br />
{<br />
Ipaddr[1] = TempA.ToString();<br />
byte[] ab = new byte[6];<br />
int len = ab.Length;<br />
int r = SendARP((int)TempA.Address, 0, ab, ref len);<br />
Ipaddr[2] = BitConverter.ToString(ab, 0, 6);<br />
}<br />
How do i "convert" that to a method and return the value if Ipaddr[2] correctly ?
like this?:
public arp()<br />
{<br />
<br />
=code=<br />
<br />
return Ipaddr[2];<br />
}
and how do i access the method in the main project file (site.aspx.cs) ?
I'm sorry to ask so many questions and answer partally on some of them.
|
|
|
|
|
using System.Net;
using System.Runtime.InteropServices;
class Arp
{
[DllImport("iphlpapi.dll", ExactSpelling = true)]
private static extern int SendARP(int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen);
public string MyMethodName()
{
string LocalHostName = Dns.GetHostName();
string[] Ipaddr = new string[3];
Ipaddr[0] = LocalHostName;
System.Net.IPHostEntry LocalIpAddress = Dns.GetHostEntry(LocalHostName);
System.Net.IPAddress[] FirstAddress = LocalIpAddress.AddressList;
foreach (IPAddress TempA in FirstAddress)
{
Ipaddr[1] = TempA.ToString();
byte[] ab = new byte[6];
int len = ab.Length;
int r = SendARP((int)TempA.Address, 0, ab, ref len);
Ipaddr[2] = BitConverter.ToString(ab, 0, 6);
}
}
}
To call this from some other code you first create an instance of Arp then you call the MyMethodName() method (you'll want to change this to a more suitable name)
Does this help?
By the way, given the price tag of Team system I doubt that you and a friend will want to use it once it is out of beta. It seems to be gears towards teams of 20+ (even although MS say 5+)
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
We Are under education in Denmark and have an aggreement with MS Academic.
We can download every Microsoft product with valid license as long we are under education.
We just want to taste team programming, so that we are prepared when we finish the education.
And yes, it confirmed my guesses. thanks for the help.
I have another problem now:
Error 2 'Arp.CollectList()': not all code paths return a value
This is the code:
using System;<br />
using System.Runtime.InteropServices;<br />
using System.Net;<br />
<br />
public class Arp<br />
{<br />
[DllImport("iphlpapi.dll", ExactSpelling = true)]<br />
public static extern int SendARP(<br />
int DestIP,<br />
int SrcIP,<br />
[Out] byte[] pMacAddr,<br />
ref int PhyAddrLen);<br />
public string CollectList()<br />
{<br />
for (int i = 20; i < 70; i++)<br />
{<br />
String sStatus;<br />
String IPString = "192.168.0." + i;<br />
string[] _splitString = IPString.Split(new char[] { '.' });<br />
<br />
int _retVal = 0;<br />
_retVal += (int)(int.Parse(_splitString[3]) * Math.Pow(256, 0));<br />
_retVal += (int)(int.Parse(_splitString[2]) * Math.Pow(256, 1));<br />
_retVal += (int)(int.Parse(_splitString[1]) * Math.Pow(256, 2));<br />
_retVal += (int)(int.Parse(_splitString[0]) * Math.Pow(256, 3));<br />
_retVal = (int)(((_retVal & 0x000000ff) << 24) +<br />
((_retVal & 0x0000ff00) << 8) +<br />
((_retVal & 0x00ff0000) >> 8) +<br />
((_retVal & 0xff000000) >> 24));<br />
<br />
byte[] ab = new byte[6];<br />
int len = ab.Length;<br />
int r = SendARP((int)_retVal, 0, ab, ref len);<br />
string sMac = BitConverter.ToString(ab, 0, 6);<br />
<br />
if (sMac == "00-00-00-00-00-00")<br />
{<br />
sStatus = "<font color = red>Offline</font>";<br />
}<br />
else<br />
{<br />
sStatus = "<font color = green>Online</font>";<br />
}<br />
<br />
}<br />
}<br />
}
|
|
|
|
|
Public string CollectList() <- It does not return a value, so i removed string and inserted void.
So now it's Public void CollectList()
|
|
|
|
|
I have a DataGrid Bounded to a DataTable. I need a way to disable auto-sorting while editing and tabbing out on a sorted column. The DataGrid should get sorted only on Column Click.
Is there a clean way to achieve this?
Live Life King Size
Alomgir Miah
|
|
|
|
|
Dear all
I have a tab control that contains 5 pages. I want to disable the last 4 pages untill I finish from the first one, then I enable the second one untile I finish it and so on.
But, How to do it????
I searched in the properties but did not find anything, is there a programmatic solution.
waitting..........
thanks
|
|
|
|
|
|
Hello
After attaching onchange event for select element I have to double-click on the select boxes to get them to show their <options>.
This is the code for event attachment:
((mshtml.HTMLSelectElementEvents2_Event)oSelect).onchange += new mshtml.HTMLSelectElementEvents2_onchangeEventHandler(this.Select_onchange)
What I'm doing wrong?
Denis
|
|
|
|
|
in an ASP.NET Web application, in the login page,wehn the user enters his username and password,i need to compare the entered username and password with the ones present in the database table. im using c# and sql server2000
plz help
|
|
|
|
|
You can authenticate users in Asp.Net by one of three ways
1-Windows Authentication
2-Forms Authentication
3-Passport Authentication
In your case use Forms Authentication
To tell Asp.Net to use it in configration file set authontication mode to forms
<authentication mode="Forms">
<forms name="MyForm" loginUrl="login.aspx" protection="All" timeout="30" />
</authentication>
In the Login Form Button Clich event handler
you can Validate aginest Sel Server database
like any SQL Query check if you have record who is name and password equal given values but be aware of sql injection attack when you build your query
MCAD
|
|
|
|
|
Mohamad Al Husseiny wrote:
SQL Query check if you have record who is name and password equal given values
I need the query to make a comparison with the values entered and the ones existing in the database.
thanx alot!
|
|
|
|
|
hi
im new to database and still figuring out how to use them... this is very urgent.. i want to retrieve a particular user's data from MS Access to my tab page of textboxes/radio buttons/combo boxes.. i want to allocate specific data in specific textboxes/radio buttons/combo boxes without using data form wizard.. i did databiding of controls to my table columns, but it's not showing when i run my app..
what should i do?
i appreciate it if you could provide me with specific details due to my time constrain..
thank you!
|
|
|
|
|
nidhelp wrote:
i did databiding of controls to my table columns, but it's not showing when i run my app..
How do you retrived the data and did data binding?
MCAD
|
|
|
|
|
what i did was only go to my textboxes/radio btns/combo boxes' properties>(databinding)>(advanced)>text>select in treeview mydataset>fieldname... in data adapter preview i can see all the users' data displayed... how do i only show a chosen user's data in textboxes/radio btns/combo boxes when i run the app.. i've a textbox for user to key in ID No. and a ok button.. can my ok button represent a load button to load the data of user whose ID no. was entered in text box? how do i go on exactly?
i've read articles already.. i learn when i actually do it, reading helps to clear some of my doubts but hands-on helps me learn faster and easier... please give me some real guidance if you are free, ok??
i suppose i still have a lot to do to achieve what i want... im rushing against time!! please help...
Thanks!!
|
|
|
|
|
I hope i understood what you need correctly
You want to display the data for the user which have Specific ID Is this OK?
if yes
if you got all the data of customer table for example into DataSet to filter the data by customer ID
Dataset DefaultView have Filter Property which you can set
And it will be filter the data
some thing like that
DataSet.Customers.DefaultView.RowFilter="CustomerID='XYZ'" ;
This will display onley the data of customer who have customerID='xyz'
So modify this code to work in your case
The other thing get the data you need only dont return all table and you really need few records to do this dont use some thing like
SELECT CustomeID,CustomerName,.. FROM Customers
You can get the data you only need by add Where Clause
like SELECT CustomeID,CustomerName,.. FROM Customers Where CustomerID='xyz'
MCAD
|
|
|
|
|
hi
you see, when i use data form wizard, the form just pop-up across my screen as i used the show form method.. my most important need now is to be able to place my form that i had generated from data form wizard INTO a tab page... i tried to copy and paste the form controls over to a tab page, the result was that the form could not load.. i want the form to be placed in a tab page which i've already created and is working well..
PLEASE help me...
thanks
|
|
|
|
|
I have searched the message board and found nothing. I want to insert from a DataSet into a Table in my DB.
I create the dataset and from there would like to insert a column from the dataset into a table I have created in the DB.
A point in the right direction or any help would be appreciated.
Scott Moore
|
|
|
|
|
Use DataAdapter and CommandBuilder. MSDN has all the information you need.
Live Life King Size
Alomgir Miah
|
|
|
|
|
As Alomgir Said you can Use DataAdabter and CommandBuilder
But at first i think you need to read tutorial or book about ado.net for now you need to do somthing like this
SqlDataAdapter da = new SqlDataAdapter(selectSql, connString);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.Fill(ds, "Customers");
da.Update(ds, "Customers");
But note that CommandBuilder not come free without price
It has limitations in areas like stored procedure,joins and concurrency handling
So it is good practice to build your Command by yourself
MCAD
|
|
|
|
|
I tried to transfer a Bitmap through a network stream but i couldn't because of a serialization matter .
the compiler told me that you have to serialize the bitmap object. How can i do that ??? or is there any alternative solution???
thanks for help
Don't smile to the world.... It does not smile to you
|
|
|
|
|
Dear all,
How can I check executing a program or opening a file on WinXP in C# ?
What's the related events ?
--TNX
|
|
|
|
|
hi my friend,
for your problem i don't get exactly what do you mean if you are trying to see if one external file is already running or not in your task manager processes list you have to know first the name of the file you would like to trace something like for example "notepad.exe"
if this is the file you want to see if it is already running or not you can do that by checking its name in your task manager processes by its name as follows
<br />
Process[] processes = System.Diagnostics.Process.GetCurrentProcesses();<br />
for(int i = 0 ; i < Processes.Length ; i++)<br />
{<br />
if(processes[i].ProcessName == "notepad")<br />
{<br />
Console.WriteLine("Yeah The File Is already Running");<br />
processes[i].Kill();<br />
}<br />
}<br />
Miss With The Best And Die Like The Rest
|
|
|
|
|
Use Proceess Class it's have method that will do that
you can Enumerate Process and check for specific process
foreach(Process p in Process.GetProcesses())
{
if(p.MainWindowTitle=="phdhdh")
}
To Start File use
Process.Start(fileName);
MCAD
|
|
|
|
|
Any one can help me in the following
i have two functions in "dll.dll" as
int addition(int a,int b);
char* functionname (char* string);
i'm calling this function in C#.NET program using
[DllImport("dll.dll")]
static extern int addition(int a,int b);
how can i declare the character pointer in C# .
Thanks
preky
|
|
|
|
|