|
AFAIK, you can't tell is a connection is wired or wireless without asking your specific router.
It presents an IP presence to the world - it does not distinguish between the connection methods.
So there are two ways to do it:
1) Tie your code to your specific router and find a way to ask that. This will be dependant on the specific make and model of router you are talking to.
2) Slightly less specific would be to set your router to use two different address ranges for wired and wireless devices - again this will probably depend on your router, but it may be possible if you use a different DCHP controller.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Hi
I want to insert data from some text box to table of sqldatabase but some field is int and some one is nvarchar how to convert text of text box to them i do below code but i have
constr = "Data Source=SAFA4-PC;Initial Catalog=StudentDb;Integrated Security=True";
System.Data.SqlClient.SqlConnection Conn = new System.Data.SqlClient.SqlConnection();
Conn.ConnectionString = constr;
Conn.Open();
System.Data.SqlClient.SqlCommand Comm = new System.Data.SqlClient.SqlCommand();
Comm.CommandText = "insert into Tbl_Student (Code ,Name ,LastName ,CityCode ,Address ,BirthDay ,FatherName ,ID,CodeMeli,tel ) values( @Code,@Name,@LastName,@FatherName,@Id,@MeliCode,@Tel,@Address,@BirthDay,@CityCombo)";
Comm.CommandType = System.Data.CommandType.Text;
Comm.Connection = Conn;
Comm.Parameters.Add("@Code", SqlDbType.Int);//, int.Parse(StudentCode.Text));
Comm.Parameters["@Code"].Value = int.Parse(StudentCode.Text);
Comm.Parameters.Add("@Name", SqlDbType.NVarChar);//Name.Text);
Comm.Parameters["@Name"].Value = Name.Text;
Comm.Parameters.Add("@LastName", SqlDbType.NVarChar);// LastName.Text);
Comm.Parameters["@LastName"].Value = LastName.Text;
Comm.Parameters.Add("@FatherName", SqlDbType.NVarChar);// FatherName.Text);
Comm.Parameters["@FatherName"].Value =FatherName.Text;
Comm.Parameters.Add("@Id", SqlDbType.Int); //int.Parse(Id.Text));
Comm.Parameters["@Id"].Value = int.Parse(Id.Text);
Comm.Parameters.Add("@MeliCode",SqlDbType.Int);
Comm.Parameters["@MeliCode"].Value = int.Parse(MeliCode.Text);
Comm.Parameters.Add("@Tel",SqlDbType.Int);
Comm.Parameters["@Tel"].Value = int.Parse(Tel.Text);
Comm.Parameters.Add("@Address",SqlDbType.NVarChar);
Comm.Parameters["@Address"].Value = Address.Text;
Comm.Parameters.Add("@BirthDay", SqlDbType.Char);// BirthDay.Text);
Comm.Parameters["@BirthDay"].Value = BirthDay.Text.ToString();
Comm.Parameters.AddWithValue("@CityCombo", CityCombo.ValueMember);
Comm.ExecuteNonQuery();
Conn.Close();
this error :
Conversion failed when converting the nvarchar value 'd' to data type int.
Please help me
|
|
|
|
|
The error is here
Quote: Comm.CommandText = "insert into Tbl_Student (Code ,Name ,LastName ,CityCode ,Address ,BirthDay ,FatherName ,ID,CodeMeli,tel ) values( @Code,@Name,@LastName,@FatherName,@Id,@MeliCode,@Tel,@Address,@BirthDay,@CityCombo)";
you are assigning
CityCode = @FatherName,
Address = @Id
BirthDay = @MeliCode
FatherName = @Tel
ID = @Tel
CodeMeli = @Address
tel = @BirthDay
and @CityCombo is extra.
check the order and insert in proper order. then it will work.
Vande Matharam - Jai Hind
|
|
|
|
|
Request you not to crosspost.
Same was asked in Q&A.
|
|
|
|
|
Beyond that, some data types were chosen wrongly.
A "Telephone number" is not an int, even when it contains didgits only: it can start with a "0", - and it could be bigger than 2^31 (10 digits or more).
"BirthDay" ought to be a DateTime, not a string.
And the "ID" ought to be generated by the SQL Server, not by the client.
|
|
|
|
|
1)We have developed a library to use it with our software & we build it as DLL
2)We developed a application using our library
Now what I need that no other user can use my library in his application for example when i give my application to end user that library is going to be added in setup, and if we dont protect it , any user can use it as reference in a .net project and can use my library and develop his own program , I need some thing that only my application will have access to my library and no other program can use it as reference and access its features
|
|
|
|
|
Please don't repost the same question.
Use the best guess
|
|
|
|
|
In order to do this, you are looking at licensing. There's a good explanation of it here[^].
|
|
|
|
|
A simple - but not very secure - method is to check the running application. If some code in your dll is called, and the running application is not your executable, throw some exception or let the application hang or randomly return wrong results...
Make sure you do not happen to hurt yourself when you use such methods.
|
|
|
|
|
1)We have developed a library to use it with our software & we build it as DLL
2)We developed a application using our library
Now what I need that no other user can use my library in his application for example when i give my application to end user that library is going to be added in setup, and if we dont protect it , any user can use it as reference in a .net project and can use my library and develop his own program , I need some thing that only my application will have access to my library and no other program can use it as reference and access its features
|
|
|
|
|
Hi All
I have a collection of pages where in each page I need to replace the reference of a control with some
other control....
Following is the line of code that I need to replace on every aspx page and there are about 90 + pages :
<%@ Register Src="../Application_Controls/Nonterm_Controls/CommonBookingEngineNonterm.ascx".
How can this be done programatically.Any help will be appreciated...
Thanks in Advance
Sumit
|
|
|
|
|
You wouldn't do this programatically - that would be complete overkill. All you you need do is a global find and replace in Visual Studio.
|
|
|
|
|
Hi,
Is it possible to download a file by passing it path to C# class library?
|
|
|
|
|
Sure. Why wouldn't it be?? Code is code. It doesn't matter if it's in a .DLL or an .EXE.
|
|
|
|
|
Ok but HttpResponse is not available in .cs files right? Can u please let me know whether am understanding it wrongly
|
|
|
|
|
Member 9617037 wrote: HttpResponse is not available in .cs Why not, it's just another .NET class? Or do you really mean HttpWebResponse [^]?
Use the best guess
|
|
|
|
|
Hey guys, dunno what I am doing wrong here... seems so simple.
Helper Class:
Class Paramaters
{
Public DateTime time = DateTime.Now;
public string formatDate = "MM/dd";
}
The Call:
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = Parameters.time.ToString(Parameters.formatDate);
}
Can anyone shed some light on what exactly I am doing wrong? Thank you.
|
|
|
|
|
taking a punt, since you dont say what error(s) you are getting ..
shouldnt Class Parameters and/or its members be 'public static' ? (else, iirc, you have to create an instance of it)
'g'
|
|
|
|
|
Wrong?? That would mean we need to know what you expected it to do. Whether it works right or wrong is relative to the expected result.
If you wanted the code to fail a certain way, well, then it would be working correctly, now wouldn't it?
|
|
|
|
|
LOL
I understand the concerns. What I have is a huge list of if statements associated with one of my buttons. They all will return this date in some way. Instead of having a million copies of the same code, I want to reference that class so when I change something within that class, it applies to all instances of the code.
The error I am getting is An object reference is require for non-static field, method, or property.
Copying the code
DateTime time = DateTime.Now;
string formatDate = "MM/dd";
textBox1.Text = time.ToString(formatDate);
In each and every if statement seems like it would be a big waste of code and space. I have about 20 buttons or so that would use it, each with 2 if statements attached. I want to just reference that code in a helper class and just have to type something like this:
textBox1.Text = Parameters.time.ToString(Parameters.formatDate);
which would return "03/11" in the text box, for today's date.
I hope this helps clarify my intentions, thanks.
|
|
|
|
|
If you want to use Parameters without creating an instance then the methods/properties/fields you are exposing need to be static. If they are all static, then the class should be static too.
You will have a problem with time if you make it static as it will only be set the first time you call it.
This will fix your problems:
public static class Paramaters
{
public const string MonthDayFormat = "MM/dd";
public static DateTime Time
{
get { return DateTime.Now; }
}
}
textBox1.Text = Paramaters.Time.ToString(Paramaters.MonthDayFormat);
|
|
|
|
|
Worked exactly as intended Dave! Thank you for clearing that up for me.
Time was a misleading description IN this case. However, this was also going to serve as my template for the time stamp portion of my next step.
How can I make Time (one that actually displays the current system time), dynamic? So if I push a button every 5 seconds, it updates the field I am pointing to to the current time?
Gosh not only do I sound like a noob, I am a babbling, confusing... noob.
Edit: Could I have it return my result into the box (or in my literal case, a log.txt file) and then turn around and reset that value?
|
|
|
|
|
No problem!
By using a property as in the code I posted, or using DateTime.Now each time directly rather than a cached field as you were attempting previously.
Edit: If you want to make it a little less wordy to access you could just create a static property or method that does it all for you:
public static class DateTimeHelpers
{
private const string MonthDayFormat = "MM/dd";
public static string NowMonthDayString
{
get { return DateTime.Now.ToString(MonthDayFormat); }
}
}
textBox1.Text = DateTimeHelpers.NowMonthDayString;
|
|
|
|
|
Sorry Dave, didn't realize you had already prevented that from becoming a problem. I just added another private const string to display hours and minutes how I desired, and it works flawlessly, you sir, are a gentleman and a scholar 
|
|
|
|
|
You're welcome
|
|
|
|
|