Click here to Skip to main content
       

C#

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: Static IP?memberPIEBALDconsult6 Jul '12 - 18:31 
Of course they can.
AnswerRe: Static IP?memberMidnight Ahri6 Jul '12 - 18:33 
PIEBALDconsult wrote:
Of course they can.

guess i've to find something else that's really static.
btw thank you. Smile | :)
AnswerRe: Static IP?memberSoMad6 Jul '12 - 19:59 
If you can get the MAC address of the network card of the computer connecting to your server, that should work for what you are describing.
There are ways to change the MAC address too, but it not something you will normally see.
 
Soren Madsen
GeneralRe: Static IP?memberRoger Wright6 Jul '12 - 20:59 
Excellent answer, Soren. Yes, the MAC address can be spoofed, but 99.999% of users won't have any idea how to do so, nor any reason to. IIRC, on a local network the ARP command will return the MAC address. On the Internet, I'm not sure that there is a way to return this information, but it's worth looking into.
Will Rogers never met me.

GeneralRe: Static IP?memberSoMad7 Jul '12 - 16:31 
Thanks Roger,
 
I agree, the OP (and just about all of us) is highly unlikely to run into anyone spoofing the MAC address, but I thought I would mention that part too.
 
Soren Madsen
GeneralRe: Static IP?mvpDave Kreskowiak7 Jul '12 - 2:47 
You haven't said what kind of application you're working on, nor if you are writing the server-side code or client side.
 
On the server-side, it doesn't matter if you're writing a ASP.NET or Windows Forms app, you cannot get the client MAC address. You'll end up getting the MAC address of the near-side of the router closest to your server, not the client MAC.
 
If you're writing client-side code in a Windows Forms app, the client get easily get it's own MAC address and send that information in a request to the server. You'll have to implement the interface on the server and client for this to work.

GeneralRe: Static IP?memberSoMad7 Jul '12 - 16:28 
I know the OP has not given a whole lot of detail, but since he posted his question in this forum, I figured it would be valid to mention the MAC address. He is looking for something that is both unique to a computer and does not change.
 
I totally agree he might not be able to acquire the MAC address and that totally depends on what he is developing.
 
Soren Madsen
AnswerRe: Static IP?memberMidnight Ahri8 Jul '12 - 15:02 
i've tried it and i got something like 50E549A6XXXX.
thank you very much. Laugh | :laugh:
QuestionC# new linq to sql file problemmemberdcof6 Jul '12 - 14:19 
In a C# 2010 application, I created a new linq to sql (*.dbml) file. When this occurred, the .net framework created a default connection string. However I want the *.dml file to use the connection string I specify.

to solve this problem, I have the following questions:

1. When I do create a new .dbml file, how to I make the .net framework use the connection string I want to use and not come up with a default connection string?

2. For an existing .dbml file that I added to the application, how can I change the default connection string to the value I really want to be used?
AnswerRe: C# new linq to sql file problemmembervinodkrebc6 Jul '12 - 20:18 
Whenever you create instance of DataContext pass the connectionstring in the constructor. This way you will be able to bypass the default connectionstring.
http://www.exploresilverlight.com
Cheers!
Vinod

GeneralRe: C# new linq to sql file problemmemberdcof7 Jul '12 - 10:27 
can you show me a code example of what you are referring to?
GeneralRe: C# new linq to sql file problemmembervinodkrebc7 Jul '12 - 17:12 
TestDataContext dataContext = new TestDataContext("connectionstring");
http://www.exploresilverlight.com
Cheers!
Vinod

QuestionC# add table to linq to sql file problemmemberdcof6 Jul '12 - 14:17 
For a C# 2010 application, I dragged a new table onto the *.dbml surface. When this occurred, the .net framework changed the exisiting connection string to a default one that it came up with instead of using the existing connection string.
 
Thus to resolve this question, I have the follwoing questions:
 
1. When I drag a new table onto the .dbml designer surface, how can I keep the .net framework from changing the existinng connection string and use the existing connection string?
 
2. For an existing .dbml file that I already dragged the table onto the .dbml designer surface, can can I fix the exisiting code so I do not need to recreate the code from scratch again?
QuestionC# filename, linenumber loggingmemberahmed zahmed6 Jul '12 - 6:44 
Some time back I watched a demo from Anders Hejlsberg where he showed how to get the filename and linenumber at compile time by declaring a function using syntax similar to the following:
 
void log(string message, string filename = _file_, int lineno = _line_)
 
I don't recall if that was something still being worked on or a proposal or if it is in an actual shipping version of C#.
 
1. Is this in some version of C#,
2. and if so what version of C# is it in?
3. And what is the actual syntax?
 
Yes, I know I can get this info in builds where a .pdb is provided through the StackFrame class. That's not what I'm asking.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

AnswerRe: C# filename, linenumber loggingmemberahmed zahmed6 Jul '12 - 7:10 
Haha, after a little more searching, I found it here[^]
 
The syntax is:
public void TraceMessage(string message,
        [CallerMemberName] string memberName = "",
        [CallerFilePath] string sourceFilePath = "",
        [CallerLineNumber] int sourceLineNumber = 0)
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

GeneralRe: C# filename, linenumber loggingmemberPIEBALDconsult6 Jul '12 - 7:28 
Tip! Tip!
 
Thumbs Up | :thumbsup:
GeneralRe: C# filename, linenumber loggingmemberahmed zahmed6 Jul '12 - 7:58 
Good idea.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

AnswerRe: C# filename, linenumber loggingmvpLuc Pattyn6 Jul '12 - 10:38 
Interesting.
It is rather new, just available since .NET 4.5
 
I use Environment.StackTrace (available since 1.0), however that is a very expensive way as it returns the whole stack trace, where one only needs the info about one or two nesting levels.
 
Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

QuestionHow to display Information window by clicking on the push pin in Google Maps in C#memberChandrakanthGaddam6 Jul '12 - 5:26 
Hi This is Chandra,
presently working on GoogleMaps. Right now i can able to bind the langitude and latitude dynamically based on selection of country. That is multiple locations i can able to display in the map.Here my problem is i want to display information window when i click any one of the location. Please find my code below in C~ as well as Asp.net
 
C# Code:-
 
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindInfo();
}
}
 
protected void bindInfo()
{
try
{
SqlConnection con = new SqlConnection("Data Source=xxx;Initial Catalog=Test;Persist Security Info=True;User ID=xxx;Password=xxx$;Connect Timeout=38000;pooling='true'; Max Pool Size=200");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetCountryNames";
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ddlPostalCode.DataTextField = "Country";
ddlPostalCode.DataValueField = "Country";
ddlPostalCode.DataSource = ds.Tables[0];
ddlPostalCode.DataBind();
con.Close();
}
catch (Exception x)
{
Response.Write(x.ToString());
 
}
}
 
private void GetLocation(string CName)
{
 
try
{
 
SqlConnection con = new SqlConnection("Data Source=xxxx;Initial Catalog=Test;Persist Security Info=True;User ID=xxxx;Password=xxxx$;Connect Timeout=38000;pooling='true'; Max Pool Size=200");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetLocationWiseInfo";
SqlParameter param = new SqlParameter();
param.ParameterName = "@Name";
param.Value = ddlPostalCode.SelectedItem.Text.ToString();
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
 
DataSet ds = new DataSet();
da.Fill(ds);
 
con.Close();
BuildScript(ds);

}
catch (Exception x)
{
Response.Write(x.ToString());
 
}
 
}

public void BuildScript(DataSet tbl)
{
string Locations = "";
foreach (DataRow dr in tbl.Tables[0].Rows)
{
if (dr["Latitude"].ToString().Trim().Length == 0)
continue;
string Latitude = dr["Latitude"].ToString();
string Longitude = dr["Longitude"].ToString();
string Sales = dr["Sales"].ToString();
Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + Latitude + "," + Longitude + ")));";
}

js.Text = @"<script type='text/javascript'>
function initialize() {
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById('map_canvas'));
map.setCenter(new GLatLng(45.05,7.6667), 2);
" + Locations + @"
map.setUIToDefault();
}
}
</script> ";

}
protected void btnPlaceName_Click(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
GetLocation(ddlPostalCode.SelectedItem.Text.ToString());
 
}
}
 

ASPX Code:
 
<body >
<form id="form1" runat="server">
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false
& type="text/javascript">
</script>

<asp:Label ID="lblName" runat="server" Text="Please Select PostalCode">
<asp:DropDownList ID="ddlPostalCode" runat="server" Width="150px"
>

<asp:Button ID="btnPlaceName" runat="server" Text="GetGeoData" onclick="btnPlaceName_Click" />
 
<asp:Panel ID="Panel1" runat="server">
<asp:Literal ID="js" runat="server" >
<asp:Literal ID="js1" runat="server" >







</form>
</body>
 
In the dataset i am getting rows like Longitude, Latitude and sales data based on selection of Country.
 
Can any one suggest me how to do that?
 
Thanks
Chandra
AnswerRe: How to display Information window by clicking on the push pin in Google Maps in C#memberWes Aday6 Jul '12 - 6:29 
How to show Sales data along with Latitude and Longitude pushpins in Google Maps in C# with Asp.Net[^]
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

AnswerRe: How to display Information window by clicking on the push pin in Google Maps in C#mvpLuc Pattyn6 Jul '12 - 10:40 
How to use PRE tags on CodeProject[^]
 
Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

QuestionQuestion about MesageBoxIcon...memberglennPattonWork6 Jul '12 - 4:59 
Hi All,
Is there a tool kit I haven't installed or is it a case of normal with VS2008 but
 MessageBox.Show("Hello ","",MessageBoxButtons.OK,MessageBoxIcon.Hand);
gives gives the cross, Asterisk gives i in a speech bubble, Error gives the cross in red, Exclamation gives a ! in a yellow triangle, Hand gives Error, Information the speech bubble with i,None gives nothing, Question gives a speech bubble with a question mark, Stop gives the white cross with the red background and Warning gives the yellow triangle with a !. This must have been updated, cured and I haven't got it, some ones got to know about it?
Glenn
GeneralRe: Question about MesageBoxIcon...mvpOriginalGriff6 Jul '12 - 6:21 
They are all there only for backward compatibility to Windows 3.1, where the icon was a Hand, held up to show the palm as a "Stop" sign.
Later version of Windows changed the icon (to make it clearer internationally) but the old names were retained so that earlier code would still compile. The original Windows constant values which display them are all the same value: http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx[^]
 

[edit]Typo - "help" for "held" - OriginalGriff[/edit]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

GeneralRe: Question about MesageBoxIcon...memberglennPattonWork8 Jul '12 - 21:40 
Ahh, makes sense!
QuestionNetworking connectionmemberS.Alexanser6 Jul '12 - 2:47 
Hello everybody.
 
I have never woked with networking, and I have a task with it:
On virtual mashine I have a Ubuntu on real mashine I have a Windows, I need to write a programm in Windows which is create a user in Ubuntu. Network connection is setup, mashines are pinging.
I try to use a NFS(Netwerk File System) but I dont know nothing about it... Please help, push me in right side.
How I can do it?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 22 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid